Inserting a new table row without copying formats


J

John

I'm using the following code to insert a new row in a table.
Sheets(ToSheet).Range(ToTable).Rows(CursorTableRowNum) _
.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
This copies all formating from the above row to the new row.

How do I change/add code to avoid copying any row format info and just set
cols 1,2,6 & 7 to General format, col 3 to numeric, no decimals, and col 4&5
to date mm/dd/yy format, while everything else sets to a default cell format.

I appreciate your help, -John
 
Ad

Advertisements

J

Joel

the default formating would be General. You could make the entire new row
General and then change columns 3 to numeric and column 4&5 to date like this

with Sheets(ToSheet).Range(ToTable)
.Rows(CursorTableRowNum).Insert Shift:=xlDown, _
CopyOrigin:=xlFormatFromLeftOrAbove
.Rows(CursorTableRowNum).numberformat = "General"
.Cells(CursorTableRowNum,"C").Numberformat = "0.00"
.Cells(CursorTableRowNum,"D").Numberformat = "mm/dd/yy"
.Cells(CursorTableRowNum,"E").Numberformat = "mm/dd/yy"
End with
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top