Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 304
Default Up and then down VB code

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Up and then down VB code

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 304
Default Up and then down VB code

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 304
Default Up and then down VB code

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. Corey Excel Programming 3 December 11th 06 05:14 AM
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM


All times are GMT +1. The time now is 09:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"