First, thanks a million to all who are here to share their expertise and to spend their time to solve the coding related problems of others. You have no clue how much you've helped me so far w/ my job.
Problem: My macro doesn't do what I want. I have an excel file w/ multiple columns. What I want is the macro 1) to look for specific headers (if they exist in the file), then 2) selects the entire column and 3) resize it as specified in the script. If the specified header doesn't exist in the file, the code should move on the next one w/o giving any error.
The code below changes the “Problem Description” size from 50 to 6 although 6 is the size for "Corrective Action Required?" header (which is not applicable in this case as that header doesn’t exist and hence the resizing requirement of 6 s/b simply ignored).
But that didn’t happened. Instead, the size of previous condition (changing the col size of “Problem Description” to 50 ) did change to 6.
Should I use a different method to write this macro and avoid using OnErrorResumeNext? Any help is greatly appreciated!
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; white-space: inherit;">OnErrorResumeNext
Cells.Find(what:="data domain", After:=ActiveCell, LookIn:= _
xlValues, lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext _
, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.EntireColumn.Select
Selection.ColumnWidth =8
OnErrorResumeNext
Cells.Find(what:="eDIM#", After:=ActiveCell, LookIn:= _
xlValues, lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext _
, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.EntireColumn.Select
Selection.ColumnWidth =6
OnErrorResumeNext
Cells.Find(what:="Problem Description", After:=ActiveCell, LookIn:= _
xlValues, lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext _
, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.EntireColumn.Select
Selection.ColumnWidth =50
OnErrorResumeNext
Cells.Find(what:="Corrective Action Required?", After:=ActiveCell, LookIn:= _
xlValues, lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext _
, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.EntireColumn.Select
Selection.ColumnWidth =6</code>
Problem: My macro doesn't do what I want. I have an excel file w/ multiple columns. What I want is the macro 1) to look for specific headers (if they exist in the file), then 2) selects the entire column and 3) resize it as specified in the script. If the specified header doesn't exist in the file, the code should move on the next one w/o giving any error.
The code below changes the “Problem Description” size from 50 to 6 although 6 is the size for "Corrective Action Required?" header (which is not applicable in this case as that header doesn’t exist and hence the resizing requirement of 6 s/b simply ignored).
But that didn’t happened. Instead, the size of previous condition (changing the col size of “Problem Description” to 50 ) did change to 6.
Should I use a different method to write this macro and avoid using OnErrorResumeNext? Any help is greatly appreciated!
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; white-space: inherit;">OnErrorResumeNext
Cells.Find(what:="data domain", After:=ActiveCell, LookIn:= _
xlValues, lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext _
, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.EntireColumn.Select
Selection.ColumnWidth =8
OnErrorResumeNext
Cells.Find(what:="eDIM#", After:=ActiveCell, LookIn:= _
xlValues, lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext _
, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.EntireColumn.Select
Selection.ColumnWidth =6
OnErrorResumeNext
Cells.Find(what:="Problem Description", After:=ActiveCell, LookIn:= _
xlValues, lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext _
, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.EntireColumn.Select
Selection.ColumnWidth =50
OnErrorResumeNext
Cells.Find(what:="Corrective Action Required?", After:=ActiveCell, LookIn:= _
xlValues, lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext _
, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.EntireColumn.Select
Selection.ColumnWidth =6</code>