ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   AUTO FORMATTING WHEN ADDING ADDITIONAL ROWS (https://www.excelbanter.com/excel-programming/331095-auto-formatting-when-adding-additional-rows.html)

DAZZA

AUTO FORMATTING WHEN ADDING ADDITIONAL ROWS
 
I have a spreadsheet which is a user list for new job costings
When additional rows are added i need to update the range to include
the new additional rows
Is there an automatic procedure or code to automatically the code as
below?

Range("A2:G407").Select

When a new code is added (in the spreadsheet ) the range will go from
a2:g407 to a2:g410

Thankyou
Darrell

With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("A1").Select
Rows("1:1").RowHeight = 23.25
Range("A1").Select
ActiveCell.FormulaR1C1 = "CODE"
Range("B1").Select
ActiveCell.FormulaR1C1 = "NAME"
Range("C1").Select
ActiveCell.FormulaR1C1 = "BANK #"
Range("D1").Select
ActiveCell.FormulaR1C1 = "REC/GRP"
Range("E1").Select
ActiveCell.FormulaR1C1 = "D/MDLE"
Range("F1").Select
ActiveCell.FormulaR1C1 = "JOB #"
Range("G1").Select
ActiveCell.FormulaR1C1 = "GST CODE"
Range("A2:G407").Select
Selection.RowHeight = 20
Range("A2").Select
End Sub


cscorp[_13_]

AUTO FORMATTING WHEN ADDING ADDITIONAL ROWS
 

Dear Sir,

Thry the following:

Range("a2").Resize(Selection.End(xlDown), 7).Select

What it does?

1. Select cell "A2" -- your first cell in the range
2. Expand the range to include the new rows added
"resize(selection.end(xldown),7).
3. Select the new range --" a2:g407"

Please, let me know if that solved your problem.

regards
Juan Carlos


--
cscorp
------------------------------------------------------------------------
cscorp's Profile: http://www.excelforum.com/member.php...o&userid=24015
View this thread: http://www.excelforum.com/showthread...hreadid=376978


Tom Ogilvy

AUTO FORMATTING WHEN ADDING ADDITIONAL ROWS
 
Unfortunately that isn't what you function does. It would use the value in
the last cell entered to determine the extent of the selection - if the
value was a 1 it would select A2:G2. If the value was not numeric, it would
raise an error. I think you meant:

Range("a2").Resize(Selection.End(xlDown).row - 1, 7).Select

--
Regards,
Tom Ogilvy


"cscorp" wrote in
message ...

Dear Sir,

Thry the following:

Range("a2").Resize(Selection.End(xlDown), 7).Select

What it does?

1. Select cell "A2" -- your first cell in the range
2. Expand the range to include the new rows added
"resize(selection.end(xldown),7).
3. Select the new range --" a2:g407"

Please, let me know if that solved your problem.

regards
Juan Carlos


--
cscorp
------------------------------------------------------------------------
cscorp's Profile:

http://www.excelforum.com/member.php...o&userid=24015
View this thread: http://www.excelforum.com/showthread...hreadid=376978





All times are GMT +1. The time now is 09:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com