ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to only change specific cells (https://www.excelbanter.com/excel-programming/328578-macro-only-change-specific-cells.html)

THT

Macro to only change specific cells
 
Hi,

This is a follow up question to a previous question I had around macros.
Not sure if I should use a macro or a function in this case.

I have File 1 (master file) with a total of 1000 rows, and File 2 (which
contains 20 of the 1000 rows) -- identical columns

For example:

File 1

Name ID
A 1
B 2
C 3
D 4
E 5

File 2
Name ID Changed (extra column)
A 1 No
C 6 Yes
D 4 No

How can I create a macro/function to only change the ID cell for "C"? I
have inserted a "changed" column in File 2 to help me identify those that
have changed.

Thanks!


JulieD

Macro to only change specific cells
 
Hi

not sure if this is the best way to approach this, but one option would be
(ensure both files are open)
in File 1 column C use the formula
=IF(ISNA(VLOOKUP(A2,[File2]Sheet2!$A$2:$B$20,2,0)),B2,VLOOKUP(A2,[File2]Sheet2!$A$2:$B$20,2,0))
and copy the formula down (move your cursor over the bottom right hand
corner of the cell, when you see a +, double click) all of column C in File
1 - this will put the value in from File 2 if there is one, or it will put
the value in from column B if the value isn't found in File 2.

Once you've checked the results in column C, you can copy them and then edit
/paste special - values back over column B if you so wish.

--
Cheers
JulieD
check out www.hcts.net.au/tipsandtricks.htm
....well i'm working on it anyway
"THT" wrote in message
...
Hi,

This is a follow up question to a previous question I had around macros.
Not sure if I should use a macro or a function in this case.

I have File 1 (master file) with a total of 1000 rows, and File 2 (which
contains 20 of the 1000 rows) -- identical columns

For example:

File 1

Name ID
A 1
B 2
C 3
D 4
E 5

File 2
Name ID Changed (extra column)
A 1 No
C 6 Yes
D 4 No

How can I create a macro/function to only change the ID cell for "C"? I
have inserted a "changed" column in File 2 to help me identify those that
have changed.

Thanks!





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

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