Insert Row with Offset

cha

New Member
Joined
Aug 16, 2011
Messages
21
Hi,
How do you insert a new row offset one column to the right?


Code:
ActiveCell.Offset(1,1).EntireRow.Insert shift:=xlDown
doesn't work.
</pre>
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I don't quite get it. What is the layout of the data, before and after the row is inserted?
 
Upvote 0
If I understand your question correctly, you want to insert a row without affecting Column A. See if this line of code does what you want...

Code:
Cells(ActiveCell.Row, 2).Resize(, Columns.Count - 1).Insert Shift:=xlDown
 
Upvote 0
Hm, that line isn't working for me. I'm getting a sizing error.
I'm trying to insert a new row below the activecell, then pasting the data 1 column to the right.
 
Upvote 0
Hm, that line isn't working for me. I'm getting a sizing error.
The code was tested before I posted it and no sizing errors occurred. If you retyped it (instead of simply copy/pasting it), then maybe you missed the comma? No matter, I am pretty sure this code is not doing what you actually want based on the additional description you just provided.

Hm, that line isn't working for me. I'm getting a sizing error.
I'm trying to insert a new row below the activecell, then pasting the data 1 column to the right.
Your descriptions (the original and this current one) are not entirely clear to me. Can you show us a short (maybe 3 rows and 4 columns) before AND after example of your data so we get a clearer picture of your intent?
 
Last edited:
Upvote 0
Each class is already mapped to a family. (A>f1, B>f2, G>f1)

The original data table from Sheet1:
<table border="0" cellpadding="0" cellspacing="0" width="192"><col style="width:48pt" span="3" width="64"> <tbody><tr style="height:15.0pt" height="20"> <td style="height:15.0pt;width:48pt" height="20" width="64">Class</td> <td style="width:48pt" width="64">Date</td> <td style="width:48pt" width="64">Duration</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">A</td> <td class="xl65" align="right">1/1/2011</td> <td>2 days</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">G</td> <td class="xl65" align="right">1/3/2011</td> <td>1 day</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">B</td> <td class="xl65" align="right">1/3/2011</td> <td>3 days</td> </tr> </tbody></table>
Sheet2 before:
<table border="0" cellpadding="0" cellspacing="0" width="227"><col style="mso-width-source:userset;mso-width-alt:1755;width:36pt" width="48"> <col style="mso-width-source:userset;mso-width-alt:1828;width:38pt" width="50"> <col style="mso-width-source:userset;mso-width-alt:2486;width:51pt" width="68"> <col style="mso-width-source:userset;mso-width-alt:2230;width:46pt" width="61"> <tbody><tr style="height:15.0pt" height="20"> <td style="height:15.0pt;width:36pt" height="20" width="48">Family</td> <td style="width:38pt" width="50">Class</td> <td class="xl65" style="width:51pt" width="68">Date</td> <td style="width:46pt" width="61">Duration</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">f1</td> <td>
</td> <td>
</td> <td>
</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">f2</td> <td>
</td> <td>
</td> <td>
</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">f3</td> <td>
</td> <td class="xl65" style="width:51pt" width="68">
</td> <td>
</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">f4</td> <td>
</td> <td class="xl65" style="width:51pt" width="68">
</td> <td>
</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">f5</td> <td>
</td> <td class="xl65" style="width:51pt" width="68">
</td> <td>
</td> </tr> </tbody></table>


Sheet2 after:
<table border="0" cellpadding="0" cellspacing="0" width="227"><col style="mso-width-source:userset;mso-width-alt:1755;width:36pt" width="48"> <col style="mso-width-source:userset;mso-width-alt:1828;width:38pt" width="50"> <col style="mso-width-source:userset;mso-width-alt:2486;width:51pt" width="68"> <col style="mso-width-source:userset;mso-width-alt:2230;width:46pt" width="61"> <tbody><tr style="height:15.0pt" height="20"> <td style="height:15.0pt;width:36pt" height="20" width="48">Family</td> <td style="width:38pt" width="50">Class</td> <td style="width:51pt" width="68">Date</td> <td style="width:46pt" width="61">Duration</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">f1</td> <td>
</td> <td>
</td> <td>
</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>A</td> <td class="xl66" align="right">1/1/2011</td> <td>2 days</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>G</td> <td class="xl66" align="right">1/3/2011</td> <td>1 day</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">f2</td> <td>
</td> <td>
</td> <td>
</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>B</td> <td class="xl66" align="right">1/3/2011</td> <td>3 days</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">f3</td> <td>
</td> <td class="xl65" style="width:51pt" width="68">
</td> <td>
</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">f4</td> <td>
</td> <td class="xl65" style="width:51pt" width="68">
</td> <td>
</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">f5</td> <td>
</td> <td class="xl65" style="width:51pt" width="68">
</td> <td>
</td> </tr> </tbody></table>
 
Upvote 0
Each class is already mapped to a family. (A>f1, B>f2, G>f1)
The charts you posted are fine with one exception... where is the above information located on the worksheet? In other words, how do we indentify which family goes with which letter?
 
Upvote 0
I used vlookup to access the Family values from a different workbook. I stored it in a variable f as variant.
 
Upvote 0
I used vlookup to access the Family values from a different workbook. I stored it in a variable f as variant.
In order to do what you asked for, we will need access to all the mappings at one time. Do you have a column for that in your original data? If not, do you have an array containing the mapping?
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,734
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top