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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

martinee

Well-known Member
Joined
Nov 4, 2003
Messages
960
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.
 

R_Stephens

Board Regular
Joined
Dec 23, 2004
Messages
143
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
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
If those are your actual ranges, this would do it too:

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

Forum statistics

Threads
1,147,621
Messages
5,742,184
Members
423,710
Latest member
Duarte85

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
Top