View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
L. Howard L. Howard is offline
external usenet poster
 
Posts: 852
Default Run two macros for two different sheets

Both codes in a standard module at present.

If I run the first one for sheet 1, I want to run the second one for sheet 2.

Calling the second code from the first does not work. Strange to me??

I have also tried to combine both in a single macro using
With Sheets(Sheet2) / End With to get the code to do its job on sheet 2, but no go.

End goal is to have them in a worksheet change event macro so when sheet 1 is changed sheet 2 is also changed.

Thanks.
Howard


Sub TopToBottom_A() '/ Moves A1
Dim LastRow As Long
LastRow = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row

Application.ScreenUpdating = False

Cells(1, 1).Cut Cells(Rows.Count, "A").End(xlUp)(2)
Range("A2").Resize(LastRow, 2).Cut Cells(1, 1)

Application.ScreenUpdating = True

End Sub


Sub TopToBottom_AB() '/ Moves A1 & B1
Dim LastRow As Long
LastRow = Sheets("Sheet2").Cells(Rows.Count, "B").End(xlUp).Row

Application.ScreenUpdating = False

Cells(1, 1).Resize(1, 2).Cut Cells(Rows.Count, "A").End(xlUp)(2)
Range("A2").Resize(LastRow, 2).Cut Cells(1, 1)

Application.ScreenUpdating = True

End Sub