Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello all,
I have this bite of code that was writen for me. What do I need to change so this works with text and not a number? Thanks Sub pGarcia() Dim evalCol As String, cl As Range Dim lRow As Long, i As Long 'Enter the letter of the evaluation column 'Column letter "I" in the sheet you sent me evalCol = "I" 'Enter the number of the row where the data starts 'Row "3" in the sheet you sent me i = 3 'This identifies the last row in the spreadsheet 'It is just easier to use the GetLastRow function 'that it is to figure out if today's data contains 'more lines than yesterday's data lRow = GetLastRow(ActiveSheet) 'Start the process Do Until i lRow With Cells(i, evalCol) 'Exits the loop early if the cells to the right 'and left are blank If IsEmpty(.Offset(0, -1)) And _ IsEmpty(.Offset(0, 1)) Then Exit Do .FormulaR1C1 = "= RC[-1]-RC[1]" Select Case .Value Case Is 0 .Value = "up" Range(.Offset(0, 1), Cells(i, _ GetLastCol(ActiveSheet))).Insert Shift:=xlDown lRow = lRow + 1 Case Is < 0 .Value = "down" Range(Cells(i, 1), Cells(i, _ .Offset(0, -1).Column)).Insert Shift:=xlDown lRow = lRow + 1 End Select End With i = i + 1 Loop Range("I3").Select End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Which part needs to work with Text??? Is it the Case statements which are
comparing Numbers or < 0??? -- HTH... Jim Thomlinson "pgarcia" wrote: Hello all, I have this bite of code that was writen for me. What do I need to change so this works with text and not a number? Thanks Sub pGarcia() Dim evalCol As String, cl As Range Dim lRow As Long, i As Long 'Enter the letter of the evaluation column 'Column letter "I" in the sheet you sent me evalCol = "I" 'Enter the number of the row where the data starts 'Row "3" in the sheet you sent me i = 3 'This identifies the last row in the spreadsheet 'It is just easier to use the GetLastRow function 'that it is to figure out if today's data contains 'more lines than yesterday's data lRow = GetLastRow(ActiveSheet) 'Start the process Do Until i lRow With Cells(i, evalCol) 'Exits the loop early if the cells to the right 'and left are blank If IsEmpty(.Offset(0, -1)) And _ IsEmpty(.Offset(0, 1)) Then Exit Do .FormulaR1C1 = "= RC[-1]-RC[1]" Select Case .Value Case Is 0 .Value = "up" Range(.Offset(0, 1), Cells(i, _ GetLastCol(ActiveSheet))).Insert Shift:=xlDown lRow = lRow + 1 Case Is < 0 .Value = "down" Range(Cells(i, 1), Cells(i, _ .Offset(0, -1).Column)).Insert Shift:=xlDown lRow = lRow + 1 End Select End With i = i + 1 Loop Range("I3").Select End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yes. Instead of number I need to compare text.
e.g. dog = dog, true dog = cat, false "Jim Thomlinson" wrote: Which part needs to work with Text??? Is it the Case statements which are comparing Numbers or < 0??? -- HTH... Jim Thomlinson "pgarcia" wrote: Hello all, I have this bite of code that was writen for me. What do I need to change so this works with text and not a number? Thanks Sub pGarcia() Dim evalCol As String, cl As Range Dim lRow As Long, i As Long 'Enter the letter of the evaluation column 'Column letter "I" in the sheet you sent me evalCol = "I" 'Enter the number of the row where the data starts 'Row "3" in the sheet you sent me i = 3 'This identifies the last row in the spreadsheet 'It is just easier to use the GetLastRow function 'that it is to figure out if today's data contains 'more lines than yesterday's data lRow = GetLastRow(ActiveSheet) 'Start the process Do Until i lRow With Cells(i, evalCol) 'Exits the loop early if the cells to the right 'and left are blank If IsEmpty(.Offset(0, -1)) And _ IsEmpty(.Offset(0, 1)) Then Exit Do .FormulaR1C1 = "= RC[-1]-RC[1]" Select Case .Value Case Is 0 .Value = "up" Range(.Offset(0, 1), Cells(i, _ GetLastCol(ActiveSheet))).Insert Shift:=xlDown lRow = lRow + 1 Case Is < 0 .Value = "down" Range(Cells(i, 1), Cells(i, _ .Offset(0, -1).Column)).Insert Shift:=xlDown lRow = lRow + 1 End Select End With i = i + 1 Loop Range("I3").Select End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You know, some times the easy thing are over looked. I did a Vlookup. Thanks
for looking at the code for me. "Jim Thomlinson" wrote: Which part needs to work with Text??? Is it the Case statements which are comparing Numbers or < 0??? -- HTH... Jim Thomlinson "pgarcia" wrote: Hello all, I have this bite of code that was writen for me. What do I need to change so this works with text and not a number? Thanks Sub pGarcia() Dim evalCol As String, cl As Range Dim lRow As Long, i As Long 'Enter the letter of the evaluation column 'Column letter "I" in the sheet you sent me evalCol = "I" 'Enter the number of the row where the data starts 'Row "3" in the sheet you sent me i = 3 'This identifies the last row in the spreadsheet 'It is just easier to use the GetLastRow function 'that it is to figure out if today's data contains 'more lines than yesterday's data lRow = GetLastRow(ActiveSheet) 'Start the process Do Until i lRow With Cells(i, evalCol) 'Exits the loop early if the cells to the right 'and left are blank If IsEmpty(.Offset(0, -1)) And _ IsEmpty(.Offset(0, 1)) Then Exit Do .FormulaR1C1 = "= RC[-1]-RC[1]" Select Case .Value Case Is 0 .Value = "up" Range(.Offset(0, 1), Cells(i, _ GetLastCol(ActiveSheet))).Insert Shift:=xlDown lRow = lRow + 1 Case Is < 0 .Value = "down" Range(Cells(i, 1), Cells(i, _ .Offset(0, -1).Column)).Insert Shift:=xlDown lRow = lRow + 1 End Select End With i = i + 1 Loop Range("I3").Select End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
Drop Down/List w/Code and Definition, only code entered when selec | Excel Worksheet Functions | |||
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. | Excel Programming | |||
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... | Excel Programming | |||
Excel code convert to Access code - Concat & eliminate duplicates | Excel Programming |