How do I read this VBA code?

W

william.mcseveney

I have a spreadsheet that contains VBA code, that basically re-arranges
an imported file. There are two tabs in the file, Raw Data and Actual
Sign on Sign Off. The problem I have is that the code was not written
by me and since then the imported data layout has changed.

Main problem is that unless I highlight the blank cells and hit the
Delete key the macro does not position the data correctly, but once I
use the delete key it all works fine, I dont understand why this is.

Here is the code in the VBA - if someone could first of all tell my
what the code is trying to do (in simple terms) and how can I get
around the problem of the data not positioning in the tab Actual Sign
on Sign Off.

Sub Signonoff()
'
' Sign On Off
' Macro recorded 09/10/2002 by pcond1
'

'
Application.ScreenUpdating = False
Sheets("Actual Sign-on Sign-Off").Range("A2:R359").ClearContents
k = 1
For l = 1 To 1500
If Sheets("Raw Data").Cells(l, 8) > 0 Then
k = k + 1
Sheets("Actual Sign-on Sign-Off").Cells(k, 1) = Sheets("Raw
Data").Cells(l, 3)
For i = 2 To 20
j = 2 * i
If Sheets("Raw Data").Cells(l + i, 12) = "" Then
Exit For
Else
Sheets("Actual Sign-on Sign-Off").Cells(k, -1 + j) = Sheets("Raw
Data").Cells(l + i, 12)
Sheets("Actual Sign-on Sign-Off").Cells(k, -2 + j) = Sheets("Raw
Data").Cells(l + i, 10)
End If
Next i
End If
Next l
Application.ScreenUpdating = True
End Sub
 
B

Bob Phillips

Loop through 1500 rows on "Raw Data" and if column H is > 0 it
copies column "C" from that row to the next free cell in column A of
"Actual Sign-on Sign-Off" sheet.

Then looks at the next 20 (missing the very next line) and if column L is
not blank, it copies column L and column J to the next free columns on the
same row of the "Actual Sign-on Sign-Off" sheet (why I have no idea?).


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top