if/else question

musicman715

New Member
Joined
Jul 15, 2011
Messages
45
Windows("Invoice - Event By Department.xls").Activate<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
Range("A18:O18").Select<o:p></o:p>
Selection.Copy<o:p></o:p>
<o:p> </o:p>
Above is the code to copy the info from cells A18-O18 in my invoice…following this above code is my code to paste that info into my data sheet. What I need is this: sometimes the info in A18-O18 is in A19-O19 because the address line in my invoice has 5 lines instead of 4 when I export this invoice to excel. I need the VBA to tell excel: “ If info is in A18-o18 copy that info, but if info is in A19-O19, copy that info instead, then proceed onto the following “pasting” command in my code.” I think I can use an if else command, but I’m not exactly sure of all the syntax.<o:p></o:p>
Any help is greatly appreciated.<o:p></o:p>
Thanks Musicman715<o:p></o:p>
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
would A19 be empty if the data you want to copy is instead in A18??? There needs to be some condition that can be tested for true/false.
 
Upvote 0
try this

Code:
Windows("Invoice - Event By Department.xls").Activate
If Range("A19") = "" Then
    Range("A18:O18").Copy
Else
    Range("A19:O19").Copy
End If
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,839
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top