Help for Printing Sheet

A

Ashish

Hello All Experts,
I am a newbie and I got the following macro from the newsgroup which is
suitable for me.

The problem is that it prints the same data and does not go forward.

I will explain my problem:

Workbook Name: MyWorkbook

Sheet Name: Data with Range Name: Database
Sheet Name: MyForm used to display different details from Data Sheet

Range Name MyList is a single column on Database Sheet and is having
Data Validation used with Vlookup to extract data on MyForm Sheet

MyList: combination of Alphabets and digits for eg. GND123LTTSH,
GND124LTDTP....., EGF123SVASM, EGF124LTASM......, first three alphabets
from left is for recognizing the company and next three digits is
running serial number starting from 111 onwards, last five digits is
for recognizing type of equipment.

When the value is selected in the dropdown box all relevant details are
filled up

I wish to print say all records of GND company from 123 to 140, or EGF
company from 123 to 135.

I need to select the value in dropdown box and say GND123LTTSH and then
give the command to print upto GND140LTASM

I am using OfficeXP/Excel 2003

Can somebody modify the below code or suggest another solution for me?
It would save me a lot of time.

Thanks to anyone who will help me.


Option Explicit
Sub testme()
Dim StartVal As Long
Dim EndVal As Long
Dim TempVal As Long
Dim iCtr As Long
Dim wks As Worksheet
'The below line edited to suit my case
Set wks = Worksheets("MyWorkbook")

StartVal = CLng(Application.InputBox(Prompt:="Start with", _
Default:=1, Type:=1))
If StartVal = 0 Then
Exit Sub
End If
EndVal = CLng(Application.InputBox(Prompt:="End with", _
Default:=StartVal + 1, Type:=1))
If EndVal = 0 Then
Exit Sub
End If
If EndVal < StartVal Then
TempVal = StartVal
StartVal = EndVal
EndVal = TempVal
End If
For iCtr = StartVal To EndVal

'The below line edited to suit my case
wks.Range("MyList").Value = iCtr

'Application.Calculate 'just in case

'The below line edited to suit my case
wks.Range("MyPrint").PrintOut Preview:=True
Next iCtr
End Sub

Ashish Kumar Singh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top