G
Guest
I am attempting to write a macro that will pull information from a spreadsheet into a list on another sheet. For instance, I have many pieces of equipment and want to see only the equipment for a certain system, so I type in the system I want, hit my button, and go. I am running into problems with searching to the next cell in the spreadsheet. This is the code I have so far
Private Sub CommandButton2_Click()
'Creating Report Number One
t = 1
System = Sheets("input").Range("E3")
Do While t < 10
ActualSystem = Sheets("electrical").Range("At")
If System = ActualSystem Then
Sheets("electrical").Range("At").Copy Destination:= _
Sheets("report").Cells(Rows.Count, 1).End(x1Up) _
.Offset(1, 0)
t = t + 1
Else
t = t + 1
End If
Loop
End Sub
I want it to put only the pieces of equipment for that particular system on the list, and I want to have it where there are no blank spaces between the pieces of equipment on the list. The system is numbered like this:
"Bxx"
with xx being any integers. I know I am referencing the cells wrong in Excel, I know you just cant say Cell (At) and have t be counted each time through, which is the problem I am running into, it gives me a runtime error whenever it gets to the ActualSystem variable. Any help on this matter would be greatly appreciated. Thanks.
Brian
Private Sub CommandButton2_Click()
'Creating Report Number One
t = 1
System = Sheets("input").Range("E3")
Do While t < 10
ActualSystem = Sheets("electrical").Range("At")
If System = ActualSystem Then
Sheets("electrical").Range("At").Copy Destination:= _
Sheets("report").Cells(Rows.Count, 1).End(x1Up) _
.Offset(1, 0)
t = t + 1
Else
t = t + 1
End If
Loop
End Sub
I want it to put only the pieces of equipment for that particular system on the list, and I want to have it where there are no blank spaces between the pieces of equipment on the list. The system is numbered like this:
"Bxx"
with xx being any integers. I know I am referencing the cells wrong in Excel, I know you just cant say Cell (At) and have t be counted each time through, which is the problem I am running into, it gives me a runtime error whenever it gets to the ActualSystem variable. Any help on this matter would be greatly appreciated. Thanks.
Brian