Sorry, Here is the attachment.
I have attached a macro enabeled worksheet that will create a Word document based on the data entered into a row.
If a user inserts a column, the offsets get messed up, and so too will the word document.
How can I dynamically maintain the column references if this occurs.
Sorry, Here is the attachment.
If I was concerned about my users mucking with the sheet, what I would do is:
- Name the header ranges. i.e. I defined a range named "rngPA" on cell A1
- Adjust your code to pick up intersects
Try defining that name first. Then make sure you have the Immediate window showing and run this code:
I think you'll get the idea.Code:irow = ActiveCell.Row Debug.Print Intersect(rows(iRow).Entirerow,Range("rngPA").EntireColumn).Address Debug.Print Intersect(rows(iRow).Entirerow,Range("rngPA").EntireColumn).Value![]()
Ken Puls, CMA, MS MVP (Excel)
Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter
If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.
Thanks Ken, worked like a charm!
Updated file attached.
Excellent! So this one is sorted, yes?![]()
Ken Puls, CMA, MS MVP (Excel)
Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter
If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.
Bookmarks