Home |
Search |
Today's Posts |
#34
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Always 3 characters at the beginning...
If yes, then I'd ask for that prefix in another inputbox. You'll have to add this portion to your current code (I've lost track of what's current). dim myPfx as string ..... mypfx = inputbox(prompt:="what's the prefix") if trim(mypfx)="" then exit sub end if mypfx = left(mypfx & space(3),3) 'pad it with trailing spaces if required. Then the other part: For Each mycell In myRng.Cells If LCase(mycell.Value) Like LCase(mypf) & "*" Then If IsNumeric(Mid(mycell.Value, 4, 3)) Then If StartVal <= Val(Mid(mycell.Value, 4, 3)) _ And EndVal = Val(Mid(mycell.Value, 4, 3)) Then wks.Range("ID").Value = mycell.Value Application.Calculate 'just in case wks.Range("PRINTAREA").PrintOut preview:=True ..... End If 'one more end if to match up with that if End Sub prkhan56 wrote: Hi Dave, Thanks a million...I have ID as sheet level name and it is working but a slight problem is occurring. May be you would be kind enough to rectify that too... Is it possible that I can type the code together with number for example EFG123 in the start box and EFG145... which would print the record from 123 to 145 for company EFG. As my numbers repeat also in some cases like ABC123 to ABC145... Now the macro prints the same number from all the companies... for eg When I put 123 in the start box and 145 in the end box.. then it will print ABC123 to ABC145, and then EFG123 to EFG145... and so on... I hope you get what I am trying to say. I have no words to express my thanks for all the time and help you have extended to me during all these days. Can the above problem be rectified? I thing the following needs to be modified : For Each myCell In myRng.Cells If IsNumeric(Mid(myCell.Value, 4, 3)) Then If StartVal <= Val(Mid(myCell.Value, 4, 3)) _ And EndVal = Val(Mid(myCell.Value, 4, 3)) Then wks.Range("ID").Value = myCell.Value Application.Calculate 'just in case wks.Range("PRINTAREA").PrintOut preview:=True the code should allow me to input the number eg ABC123 in the beginning box and ABC145 in the second input box... and then print accordingly Thanks a million once again. Rashid Khan -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Active cell counting in particular print page (one sheet having different print area) | Excel Worksheet Functions | |||
Why do I get a print error light trying to print an excel sheet ? | Excel Discussion (Misc queries) | |||
Need Code To Print From Code Modules | Excel Programming | |||
how to use Excel to generate alphabet serially | Excel Worksheet Functions | |||
Help with Mr. Dave Peterson's Code for Consolidating Many Sheets to One | Excel Programming |