Looping

  • Thread starter Thread starter Andrew Clark
  • Start date Start date
A

Andrew Clark

Hello,

I have a spreadsheet that is essentially a database of employees and
their weekly schedules. I am trying to write a macro that will loop
through the entire sheet taking an employee and their information one row
at a time. I don't really know VBA at all, but I (hope I) am competent
enough to pick it up quickly.

This is pseudocode for what I want:

while ( another_row ) {
read ( name );
read ( schedule );
write_to_file ( name, schedule );
}

Thanks!

Andrew
 
This is sort of simple, but it is a start, if you have
not used VB. It just makes a sort of copy of what already
exists.
Sub Macro1()
Do While ActiveCell.Value <> ""
ActiveCell.Offset(1, 0).Select
ActiveCell.Range("A1:B1").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
Selection.End(xlDown).Select
If ActiveCell.Row = 65536 Then
Range("A1").Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Else
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
End If
Sheets("Sheet1").Select
Application.CutCopyMode = False
'ActiveCell.Offset(1, 0).Range("A1:B1").Select
Loop
Sheets("Sheet1").Select
End Sub
 
Back
Top