Code Modification??

  • Thread starter Thread starter dkenebre
  • Start date Start date
D

dkenebre

How do I update the following code to perform the same
task column 63 in 91 (in addition for column 64 in 92,
65 in 93, 67 in 94, 68 in 95, 69 in 96, 73 in 97, 74 in 98,
76 in 99 and 77 in 100)

Sub hashbrown()
Dim holdvar
Dim COUNTERVAR
COUNTERVAR = 510
For CELLCOUNTER = 495 To 2000
If Cells(CELLCOUNTER, 63).Text = "#" And holdvar <> "" Then

Cells(COUNTERVAR, 91).Value = holdvar
COUNTERVAR = COUNTERVAR + 1
holdvar = ""
ElseIf Len(Cells(CELLCOUNTER, 63).Value) > 0 Then
holdvar = Cells(CELLCOUNTER, 63).Value
End If
Next
End Su
 
Sub hashbrown()
Dim holdvar
Dim COUNTERVAR
COUNTERVAR = 510
for column = 63 to 77
For CELLCOUNTER = 495 To 2000
If Cells(CELLCOUNTER, column).Text = "#" And holdvar <> "" Then

Cells(COUNTERVAR, column+91-63).Value = holdvar
COUNTERVAR = COUNTERVAR + 1
holdvar = ""
ElseIf Len(Cells(CELLCOUNTER, column).Value) > 0 Then
holdvar = Cells(CELLCOUNTER, column).Value
End If
Next
next
End Sub
 
Thanks pmarino,

Your code modification worked, but the answer columns did not start o
the same row, rather the next row after the previous column ended.
So I the following modification worked fine:

Sub hashbrown2()
Dim holdvar
Dim COUNTERVAR
Dim columncounter
'this loop needs to be carried out a number of times
For columnvar = 63 To 77
If columnvar = 63 Or columnvar = 64 Or columnvar = 65 Or columnva
= 67 Or columnvar = 68 Or columnvar = 69 Or columnvar = 73 Or columnva
= 74 Or columnvar = 76 Or columnvar = 77 Then
COUNTERVAR = 510
For CELLCOUNTER = 495 To 2000
If Cells(CELLCOUNTER, columnvar).Text = "#" And holdvar <
"" And holdvar <> "#" Then

Cells(COUNTERVAR, 91 + columncounter).Value = holdvar
COUNTERVAR = COUNTERVAR + 1
holdvar = ""
ElseIf Len(Cells(CELLCOUNTER, columnvar).Value) > 0 Then
holdvar = Cells(CELLCOUNTER, columnvar).Value
End If
Next
columncounter = columncounter + 1
End If
Next
End Su
 
Back
Top