Attached is the macro code I need help with. I want to define the end of the range (to the last occupied cell) in the code. currently the range is fixed based upon the initial use of code.(I attached a listing of the code to reference). Can anyone assist?
Thx in advance! Dave Sub Macro_PMT() ' ' Macro_PMT Macro ' ' Sheets("EXP").Select Rows("1:1").Select Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove Range("A1").Select ActiveCell.FormulaR1C1 = "=EXP/8" Range("B1").Select ActiveCell.FormulaR1C1 = "'=TOTAL" With ActiveCell.Characters(Start:=1, Length:=6).Font .Name = "Arial" .FontStyle = "Regular" .Size = 10 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic .TintAndShade = 0 .ThemeFont = xlThemeFontNone End With Sheets("CAP").Select Rows("1:1").Select Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove Range("A1").Select ActiveCell.FormulaR1C1 = "=CAP/8" Range("B1").Select ActiveCell.FormulaR1C1 = "'=TOTAL" With ActiveCell.Characters(Start:=1, Length:=6).Font .Name = "Arial" .FontStyle = "Regular" .Size = 10 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic .TintAndShade = 0 .ThemeFont = xlThemeFontNone End With ActiveCell.SpecialCells(xlLastCell).Select ActiveWorkbook.Names.Add Name:="CAP", RefersToR1C1:="=CAP!R13C26" ActiveWorkbook.Names("CAP").Comment = "" Range("A1").Select Sheets("EXP").Select ActiveCell.SpecialCells(xlLastCell).Select ActiveWorkbook.Names.Add Name:="EXP", RefersToR1C1:="=EXP!R13C26" ActiveWorkbook.Names("EXP").Comment = "" Range("A1").Select Selection.NumberFormat = "0.0" Sheets("CAP").Select Selection.NumberFormat = "0.0" Rows("1:1").Select Range("F16").Select End Sub -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/pages/discussexcelcom/160307843985936?v=wall&ref=ts