if then, if not then

isacp

Board Regular
Joined
Dec 16, 2004
Messages
135
im am writing a if then code.
i was wondering if there is a statement that says

if cell=1 then copy range("b3")
if not then copy range("c3")?
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Perhaps:
Code:
If cell = 1 Then
     Range("B3").Copy Range("A1")
Else
     Range("C3").Copy Range("A1")
End IF
This will copy the cells into A1. Change to suite. HTH.
 
Upvote 0
Hi there,

You probably need to use an if...else statement
For example this checks cell A3, and if its 1 will copy B3, else C3

If Range("A3").Value = 1 Then
Range("B3").Copy
Else
Range("C3").Copy
End If

Hope this helps

Richard
 
Upvote 0
If those are your actual ranges, this would do it too:

Code:
Cells(3, 3 + (cell = 1)).Copy
 
Upvote 0

Forum statistics

Threads
1,214,636
Messages
6,120,669
Members
448,977
Latest member
moonlight6

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