Link to home
Create AccountLog in
Avatar of Steve Lowry
Steve LowryFlag for United States of America

asked on

Change values in row based on multiple criteria

I download a worksheet that contains numerous columns, but the number of columns may be different based on the query.  I would like to keep four of the columns where the header values are always the same, but those columns may not always be in the same location.  

I have a macro that will delete columns based on a particular header value.  I need a macro that will change the unwanted headers to a particular value.
Avatar of Shanan212
Shanan212
Flag of Canada image

Changing the header is easy as this

range("A1").value = "NEW HEADER"

^ You can place that in your 'delete column' macro and add further ranges as well (by changing the "A1" part
Avatar of Steve Lowry

ASKER

Thanks for the response.  

Based on the query, I have worksheets with 10 columns with headers labeled "A" through "J", and sometimes I have worksheets with 26 columns with headers labeled "A" through "Z".  Headers "B", "D", "G" and "H" could appear in any location in the worksheet despite of the number of columns.  I want to change all headers that are not labeled "B", "D", "G" and "H" to "NEW HEADER".
ASKER CERTIFIED SOLUTION
Avatar of Shanan212
Shanan212
Flag of Canada image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
I tried it and it is putting New Header in all of the cells.  I made sure that the letters were capitalized.
Can you try again? I changed the code in the middle
Thanks for your help today.