Replace a cell (I2) with a cell (H2) if I2 = "a"

  • Thread starter Thread starter THINKINGWAY
  • Start date Start date
T

THINKINGWAY

I am trying to replace a cell I2 with a cell H2's contents if cell I2 is
equal to the letter a. NOTE: The cell has the letter a preceeded by the
single quote: 'a

It, the single quote, of course is not visible, but when you look in the
formula display box you can see the single quote. Thanks. Also, if this is
code, could you tell me how to inject/insert the code into the excel
spreadsheet and then run it.

Thanks
 
Hi,

In a code module, add the following code
''' ------------------------------------------
Sub Test()
dim Wsh as worksheet
Set Wsh = ActiveSheet
If Wsh.Range("I2").Value="a" Then
Wsh.Range("i2").Value=Wsh.Range("j2").Value
End If
End Sub
''' -----------------------------------------
To run the macro, select the sheet requiring the change, go to menu
Tools>Macro>Macros and choose Test (which is the name of the SUb ie 1st line
of code above; you can change it to whatever you want.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top