Hi I am very new to Excel VBA
I want to change row and column values My data is similar to this
My age is My height is My weight is
between 10-20 150 45
between 21-30 170 56
between 10-20 155 60
between 10-20 160 53
between 21-30 173 68
I want to make the data like this
Age Hght Wght
Category A 150 45
Category B 170 56
Category A 155 60
Category A 160 53
Category B 173 68
ie I changed the first row
Then I changed all "between 10-20" to "Category A" and "between 21-30" to "Category B"
I prefer not to use column numbers in code, instead I prefer to use column names.
ie like this, If Age="between 10-20" then Age="Category A"
How can we do it?
First of all, make sure you put the data in the table. (not simply type in the data in the excel's cells)
You should go to INSERT ribbon there insert the table.
Next, follow the advice from @Bryon, create another table called "DataTable" like following figure. You may create this table at another worksheet (eg MyData)
Lastly, you create another table called "MyResult". At the 1st row of the table, put the formula in the cell as following based on the columns :
=VLOOKUP(AgeTable[@[My age is]],DataTable,2,TRUE)
column 2
=VLOOKUP(AgeTable[@[My Height is]],AgeTable[@[My Height is]],1,TRUE)
column 3
=VLOOKUP(AgeTable[@[My Weight is]],AgeTable[@[My Weight is]],1,TRUE)
Following is the output of the table:
Whenever values had been change at column 2 and column 3 of table 1, it will change the column 2 and column 3 of table 3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.