Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
What does this do?
RH,
RNum is simply a variable used as a counter in the For ... Next loop. First time through the loop it will be set to 1, 2 on the second, etc. until it gets to the value in MRow. Typically it will be used in the loop to refer to something else. MRow is just a numeric value of the number input by the user at the start, with 10 added. -- HTH Bob Phillips "RH" wrote in message ... I'm working on an Excel project and ran across this code snippet: ########################### temp = InputBox(prompt:="Enter the Number of the last row shown on the screen (i.e. 1130):", _ Title:="Length of File", Default:="2000") If temp = "" Then MsgBox prompt:="Convert Data Procedure Canceled." Range("a1").Select Exit Sub Else End If Columns("A:A").Select Selection.Delete Shift:=xlToLeft MRow = CSng(temp + 10) 'Converts temp from string to number counter1 = 0 For Rnum = 1 To MRow ############################## So, in this case....What is RNUM? I don't understand the "= 1 TO MROW" here. Can someone elaborate please? Thanks! Bob |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
What does this do?
Thanks for the folowups guys! now I get it!!
Now that I got the loop worked out,I have another question... I want to modify my code to search for a cell with a specific value in it, then search for ANOTHER cell with a specific value and then select all the ENTIRE ROWS that are between the two cells it found. I've been trying to use the range object to do this, but I'm so rusty!! I only get to do VBA/Excel programming about once per year. So, I'm having a hard time with it. Any pointers?? -----Original Message----- RH, RNum is simply a variable used as a counter in the For ... Next loop. First time through the loop it will be set to 1, 2 on the second, etc. until it gets to the value in MRow. Typically it will be used in the loop to refer to something else. MRow is just a numeric value of the number input by the user at the start, with 10 added. -- HTH Bob Phillips "RH" wrote in message ... I'm working on an Excel project and ran across this code snippet: ########################### temp = InputBox(prompt:="Enter the Number of the last row shown on the screen (i.e. 1130):", _ Title:="Length of File", Default:="2000") If temp = "" Then MsgBox prompt:="Convert Data Procedure Canceled." Range("a1").Select Exit Sub Else End If Columns("A:A").Select Selection.Delete Shift:=xlToLeft MRow = CSng(temp + 10) 'Converts temp from string to number counter1 = 0 For Rnum = 1 To MRow ############################## So, in this case....What is RNUM? I don't understand the "= 1 TO MROW" here. Can someone elaborate please? Thanks! Bob . |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
What does this do?
Alright Tim,
My brain is smking now! ;-) Bob -----Original Message----- Dim rng as Range, rng1 as Range, rng2 as Range Dim cell as Range 'find the bottom of the data in Column A, search from A1 ' to the bottom of the data set rng = Range(Cells(1,1),Cells(rows.count,1).end(xlup)) for each cell in rng if cell.Value = "Target1" and rng1 is nothing then _ set rng1 = cell if cell.Value = "Target2" and rng2 is nothing then set rng2 = cell exit for end if Next if not rng1 is nothing and not rng2 is nothing then Range(rng1,rng2).EntireRow.Select else msgbox "at least one target not found" End if -- Regards, Tom Ogilvy "RH" wrote in message ... Thanks for the folowups guys! now I get it!! Now that I got the loop worked out,I have another question... I want to modify my code to search for a cell with a specific value in it, then search for ANOTHER cell with a specific value and then select all the ENTIRE ROWS that are between the two cells it found. I've been trying to use the range object to do this, but I'm so rusty!! I only get to do VBA/Excel programming about once per year. So, I'm having a hard time with it. Any pointers?? -----Original Message----- RH, RNum is simply a variable used as a counter in the For ... Next loop. First time through the loop it will be set to 1, 2 on the second, etc. until it gets to the value in MRow. Typically it will be used in the loop to refer to something else. MRow is just a numeric value of the number input by the user at the start, with 10 added. -- HTH Bob Phillips "RH" wrote in message ... I'm working on an Excel project and ran across this code snippet: ########################### temp = InputBox(prompt:="Enter the Number of the last row shown on the screen (i.e. 1130):", _ Title:="Length of File", Default:="2000") If temp = "" Then MsgBox prompt:="Convert Data Procedure Canceled." Range("a1").Select Exit Sub Else End If Columns("A:A").Select Selection.Delete Shift:=xlToLeft MRow = CSng(temp + 10) 'Converts temp from string to number counter1 = 0 For Rnum = 1 To MRow ############################## So, in this case....What is RNUM? I don't understand the "= 1 TO MROW" here. Can someone elaborate please? Thanks! Bob . . |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
What does this do?
I utilized this code and I keep getting the "At least one
Target not found" messagebox even though I've modified it and I know for a certain that the data is there. Any thought? Bob -----Original Message----- Dim rng as Range, rng1 as Range, rng2 as Range Dim cell as Range 'find the bottom of the data in Column A, search from A1 ' to the bottom of the data set rng = Range(Cells(1,1),Cells(rows.count,1).end(xlup)) for each cell in rng if cell.Value = "Target1" and rng1 is nothing then _ set rng1 = cell if cell.Value = "Target2" and rng2 is nothing then set rng2 = cell exit for end if Next if not rng1 is nothing and not rng2 is nothing then Range(rng1,rng2).EntireRow.Select else msgbox "at least one target not found" End if -- Regards, Tom Ogilvy "RH" wrote in message ... Thanks for the folowups guys! now I get it!! Now that I got the loop worked out,I have another question... I want to modify my code to search for a cell with a specific value in it, then search for ANOTHER cell with a specific value and then select all the ENTIRE ROWS that are between the two cells it found. I've been trying to use the range object to do this, but I'm so rusty!! I only get to do VBA/Excel programming about once per year. So, I'm having a hard time with it. Any pointers?? -----Original Message----- RH, RNum is simply a variable used as a counter in the For ... Next loop. First time through the loop it will be set to 1, 2 on the second, etc. until it gets to the value in MRow. Typically it will be used in the loop to refer to something else. MRow is just a numeric value of the number input by the user at the start, with 10 added. -- HTH Bob Phillips "RH" wrote in message ... I'm working on an Excel project and ran across this code snippet: ########################### temp = InputBox(prompt:="Enter the Number of the last row shown on the screen (i.e. 1130):", _ Title:="Length of File", Default:="2000") If temp = "" Then MsgBox prompt:="Convert Data Procedure Canceled." Range("a1").Select Exit Sub Else End If Columns("A:A").Select Selection.Delete Shift:=xlToLeft MRow = CSng(temp + 10) 'Converts temp from string to number counter1 = 0 For Rnum = 1 To MRow ############################## So, in this case....What is RNUM? I don't understand the "= 1 TO MROW" here. Can someone elaborate please? Thanks! Bob . . |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
What does this do?
I ran this:
Sub AAASelect() Dim rng As Range, rng1 As Range, rng2 As Range Dim cell As Range 'find the bottom of the data in Column A, search from A1 ' to the bottom of the data Set rng = Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp)) For Each cell In rng If cell.Value = "Target1" And rng1 Is Nothing Then _ Set rng1 = cell If cell.Value = "Target2" And rng2 Is Nothing Then Set rng2 = cell Exit For End If Next If Not rng1 Is Nothing And Not rng2 Is Nothing Then Range(rng1, rng2).EntireRow.Select Else MsgBox "at least one target not found" End If End Sub on this data in Column A of the active sheet starting in A1 1 2 3 4 5 6 7 8 9 Target1 10 11 12 13 14 15 16 Target2 17 18 21 22 23 24 25 It worked fine for me. As written, it would be case sensitive. TOM < tom -- Regards, Tom "RH" wrote in message ... I utilized this code and I keep getting the "At least one Target not found" messagebox even though I've modified it and I know for a certain that the data is there. Any thought? Bob -----Original Message----- Dim rng as Range, rng1 as Range, rng2 as Range Dim cell as Range 'find the bottom of the data in Column A, search from A1 ' to the bottom of the data set rng = Range(Cells(1,1),Cells(rows.count,1).end(xlup)) for each cell in rng if cell.Value = "Target1" and rng1 is nothing then _ set rng1 = cell if cell.Value = "Target2" and rng2 is nothing then set rng2 = cell exit for end if Next if not rng1 is nothing and not rng2 is nothing then Range(rng1,rng2).EntireRow.Select else msgbox "at least one target not found" End if -- Regards, Tom Ogilvy "RH" wrote in message ... Thanks for the folowups guys! now I get it!! Now that I got the loop worked out,I have another question... I want to modify my code to search for a cell with a specific value in it, then search for ANOTHER cell with a specific value and then select all the ENTIRE ROWS that are between the two cells it found. I've been trying to use the range object to do this, but I'm so rusty!! I only get to do VBA/Excel programming about once per year. So, I'm having a hard time with it. Any pointers?? -----Original Message----- RH, RNum is simply a variable used as a counter in the For ... Next loop. First time through the loop it will be set to 1, 2 on the second, etc. until it gets to the value in MRow. Typically it will be used in the loop to refer to something else. MRow is just a numeric value of the number input by the user at the start, with 10 added. -- HTH Bob Phillips "RH" wrote in message ... I'm working on an Excel project and ran across this code snippet: ########################### temp = InputBox(prompt:="Enter the Number of the last row shown on the screen (i.e. 1130):", _ Title:="Length of File", Default:="2000") If temp = "" Then MsgBox prompt:="Convert Data Procedure Canceled." Range("a1").Select Exit Sub Else End If Columns("A:A").Select Selection.Delete Shift:=xlToLeft MRow = CSng(temp + 10) 'Converts temp from string to number counter1 = 0 For Rnum = 1 To MRow ############################## So, in this case....What is RNUM? I don't understand the "= 1 TO MROW" here. Can someone elaborate please? Thanks! Bob . . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|