I am trying to achieve the following automation in VBA. I have different Sheets with wrong headers. I have another sheet called "HeadersMap", which contains the list of all Sheets's correct headers. What I want to do is, if I open a "Sheet1" then the code should go to the "HeadersMap" sheet > check the opened sheet name in the "SheetNames" column > check the Original header in "OriginalHeaders" column and copy correct header name from the "Correct Headers" column and replace the headers in the "Sheet1". And similarly , if I open "Sheet2", it should do the same.
"SHEET1"
| A | B | C | |
|---|---|---|---|
| 1 | aplpe | baanann | Roange |
| 2 | |||
| 3 |
SHEET "HEADERSMAP"
| A | B | C | |
|---|---|---|---|
| 1 | SheetNames | OriginalHeaders | CorrectHeaders |
| 2 | Sheet1 | aplpe | Apple |
| 3 | Sheet1 | baanann | Banana |
| 4 | Sheet1 | Roange | Orange |
| 5 | Sheet2 | sgura | Sugar |
| 6 | Sheet2 | Jggaery | Jaggery |
| 7 | Sheet3 | Dtergetn | Detergent |
| 8 | Sheet3 | poas | Soap |
| 9 | Sheet3 | Lfua | Lufa |
Desired Result "SHEET1"
| A | B | C | |
|---|---|---|---|
| 1 | Apple | Banana | Orange |
| 2 | |||
| 3 |