ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Replace a cell (I2) with a cell (H2) if I2 = "a" (https://www.excelbanter.com/excel-programming/402965-replace-cell-i2-cell-h2-if-i2-%3D.html)

THINKINGWAY

Replace a cell (I2) with a cell (H2) if I2 = "a"
 
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


sebastienm

Replace a cell (I2) with a cell (H2) if I2 = "a"
 
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
ToolsMacroMacros and choose Test (which is the name of the SUb ie 1st line
of code above; you can change it to whatever you want.)

--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"THINKINGWAY" wrote:

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



All times are GMT +1. The time now is 12:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com