View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Run two macros for two different sheets

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.


Try...

Sub TopToBottom(SourceRng As Range, Col$, Size&)
Dim lRow&
With SourceRng.Parent
lRow = .Cells(.Rows.Count, Col).End(xlUp).Row
SourceRng.Cut .Cells(.Rows.Count, "A").End(xlUp)(2)
.Range("A2").Resize(lRow, Size).Cut .Cells(1, 1)
End With 'SourceRng.Parent
End Sub

Sub Test_TopToBottom()
Application.ScreenUpdating = False
TopToBottom Sheets("Sheet1").Cells(1, 1), "A", 2
TopToBottom Sheets("Sheet2").Cells(1, 1).Resize(1, 2), "B", 2
Application.ScreenUpdating = True
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion