Steve Lowry
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.
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.
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".
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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
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
ASKER
Thanks for your help today.
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