nyrangers1994
New Member
- Joined
- Aug 30, 2011
- Messages
- 17
I've got a couple different scenarios where I need help with writing vba for. I know I can do this via excel formulas and a manual approach, but I need to do it as a macro because my company's admin staff will need to do this on a daily basis so an automated works best.
In my first situation, I have two columns in my activesheet that have "Starting Date" and "Duration" as the column headings in Row 1. Starting Date is in column J and Duration is in column K. Currently my macro converts some of the raw data in the other columns and then turns the entire range of used cells from column A through column U into an Excel table (Listobject) which is referenced as "Table" in my current code.
I need to modify these columns within my Listobject by taking the Duration which is always a text field such that a typical value would be "4 weeks", and puts it on a new line within the Starting Date cell on a separate line, changes the column heading for Starting Date, and then deletes the Duration column, such that:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Starting Date[/TD]
[TD]Duration[/TD]
[/TR]
[TR]
[TD]01/01/13[/TD]
[TD]4 weeks[/TD]
[/TR]
[TR]
[TD]02/02/13[/TD]
[TD]6 weeks[/TD]
[/TR]
</tbody>[/TABLE]
Becomes:
[TABLE="class: grid, width: 300"]
<tbody>[TR]
[TD]Starting Date / Duration[/TD]
[/TR]
[TR]
[TD]01/01/13
4 weeks
[/TD]
[/TR]
[TR]
[TD]02/02/13
6 weeks[/TD]
[/TR]
</tbody>[/TABLE]
In my second situation, I have two columns other columns in my Listobject called "Title" and "Number". They're both in Row 1, and Title is in column H, and Number is in column I. If the value within the number field is greater than 1, I need it to copy/paste it next to the Title surrounded by parantheses, but not delete the Number column such that:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Title[/TD]
[TD]Number[/TD]
[/TR]
[TR]
[TD]This is Title 1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]This is Title 2[/TD]
[TD]2[/TD]
[/TR]
</tbody>[/TABLE]
Becomes:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Title[/TD]
[TD]Number[/TD]
[/TR]
[TR]
[TD]This is Title 1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]This is Title 2 (2)[/TD]
[TD]2[/TD]
[/TR]
</tbody>[/TABLE]
Thank you very much for any help, guidance, or suggested code that you can provide.
In my first situation, I have two columns in my activesheet that have "Starting Date" and "Duration" as the column headings in Row 1. Starting Date is in column J and Duration is in column K. Currently my macro converts some of the raw data in the other columns and then turns the entire range of used cells from column A through column U into an Excel table (Listobject) which is referenced as "Table" in my current code.
I need to modify these columns within my Listobject by taking the Duration which is always a text field such that a typical value would be "4 weeks", and puts it on a new line within the Starting Date cell on a separate line, changes the column heading for Starting Date, and then deletes the Duration column, such that:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Starting Date[/TD]
[TD]Duration[/TD]
[/TR]
[TR]
[TD]01/01/13[/TD]
[TD]4 weeks[/TD]
[/TR]
[TR]
[TD]02/02/13[/TD]
[TD]6 weeks[/TD]
[/TR]
</tbody>[/TABLE]
Becomes:
[TABLE="class: grid, width: 300"]
<tbody>[TR]
[TD]Starting Date / Duration[/TD]
[/TR]
[TR]
[TD]01/01/13
4 weeks
[/TD]
[/TR]
[TR]
[TD]02/02/13
6 weeks[/TD]
[/TR]
</tbody>[/TABLE]
In my second situation, I have two columns other columns in my Listobject called "Title" and "Number". They're both in Row 1, and Title is in column H, and Number is in column I. If the value within the number field is greater than 1, I need it to copy/paste it next to the Title surrounded by parantheses, but not delete the Number column such that:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Title[/TD]
[TD]Number[/TD]
[/TR]
[TR]
[TD]This is Title 1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]This is Title 2[/TD]
[TD]2[/TD]
[/TR]
</tbody>[/TABLE]
Becomes:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Title[/TD]
[TD]Number[/TD]
[/TR]
[TR]
[TD]This is Title 1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]This is Title 2 (2)[/TD]
[TD]2[/TD]
[/TR]
</tbody>[/TABLE]
Thank you very much for any help, guidance, or suggested code that you can provide.