Discussion Locked

Excel VBA - Scan Column Range

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hello

I need to amend the range of columns. Instead of going from G to L, I need it to go from G to J, and include L. That means Column K is omited. Here is the code:

For i = 103 To 108 'Column G to L 103-108
Worksheets("SGAUST").Activate
If Len(Range(Chr(i) & intActiveRow).Value) < 2 Then
Else
intSeq = intSeq + 1
strETA = Convert_Date(CDate(Range(Chr(i) & intActiveRow).Value))
strPort = Convert_Port(CStr(Range(Chr(i) & PORTROW).Value))

What should I do? I tried to change to:

For i = 103 To 106 & 108

But I had an error on the Len line. Pls advise.

Thanks in advance.

3 replies

by nikki96

Just skip over it.

For i = 103 To 108 'Column G to L 103-108, exclude K
If i != 107 Then
Worksheets("SGAUST").Activate
If Len(Range(Chr(i) & intActiveRow).Value) < 2 Then
Else
intSeq = intSeq + 1
strETA = Convert_Date(CDate(Range(Chr(i) & intActiveRow).Value))
strPort = Convert_Port(CStr(Range(Chr(i) & PORTROW).Value))
End If

HTH

by crispin_yuen

Thanks for your reply. I tried your solution, but I got a return error. Do I need to place a GoTo after If i!=107 Then? I managed to get a solution to this, by placing If i=107, exist function. This works fine. Thanks to Paul! But thank you for youradvise.

This discussion is closed to new replies.