ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Conditional Copy Paste Macro (https://www.excelbanter.com/excel-discussion-misc-queries/78112-conditional-copy-paste-macro.html)

WH

Conditional Copy Paste Macro
 
I want to creat a conditional macro that if say Sheet1 has data copy the data
to Sheet2, but if Sheet1 is blank do nothing and go on to the next macro.
Can anyone help. Thank you in advance.

Bill

Gary''s Student

Conditional Copy Paste Macro
 
This is an example that only looks at one cell:


Sub Macro1()
Call Macro10
Call Macro11
End Sub

Sub Macro11()
MsgBox ("IN 11")
End Sub

Sub Macro10()
Dim r1, r2 As Range
Set r1 = Worksheets("Sheet1").Range("A1")
Set r2 = Worksheets("Sheet2").Range("A1")
If r1.Value = "" Then
Else
r1.Copy r2
End If
End Sub

Macro10 is the conditional one. If A1 in sheet1 is empty, Macro 10 just
exits. Otherwise it does the copy before exiting
--
Gary's Student


"WH" wrote:

I want to creat a conditional macro that if say Sheet1 has data copy the data
to Sheet2, but if Sheet1 is blank do nothing and go on to the next macro.
Can anyone help. Thank you in advance.

Bill



All times are GMT +1. The time now is 02:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com