VBA Copy and Paste with If statement

cguy3000

New Member
Joined
May 30, 2019
Messages
15
Hey guys so I am having a issue getting my VBA to recognize my if elseif statement in macro. I want it to read the value of a cell and if the cell is not blank then copy the entire row say A45 to S45 and then copy it, go to a different sheet, insert a new row after the last row of data, and then paste the information into the new row. However if the cell is blank I want it to just do nothing!!

So far it just seems like my macro ignores part of my if elseif statement and will only do one or the other but it cant tell when the cell is empty or not!

This is the code I currently have that isnt working.

Sheets("SOURCE DATA").Select




If IsEmpty(C45) = False Then


Sheets("Boise Historical Data").Select


Sheets("SOURCE DATA").Select


Range("C45:S45").Copy


Sheets("Boise Historical Data").Activate


Range("A1").End(xlDown).Select


r = Selection.Row
Cells(r + 1, 1).EntireRow.Insert


Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues

Else
End If


Sheets("Boise Historical Data").Activate


End Sub



And this wont do what I want it to. It will work if there is some string of characters in C45 but when I make the cell blank it will still copy the row but with C45 still being empty and its not supposed to!

Any help would be great!
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Change this
Code:
If IsEmpty(C45) = False Then
to
Code:
If Range("C45")<>"" then
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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