Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Insert Named Range using Excel Macro

Hi Ipahal,

Try:

Activesheet.UsedRange.Name = "ARImportFile"


---
Regards,
Norman



wrote in message
ups.com...
Hello,

I have a macro that formats my Excel worksheet but I'm having a problem
figuring out how to do the last step. I need to select all cells in
the worksheet and Insert a Named Range, but the number of rows in the
sheet will be constantly changing.

I tried recording the macro clicking on A1 then using 'Ctrl+Shift+End'
to select all rows in my sheet (A1:J38). This works fine for the sheet
I'm working in, but the macro is recording the physical cells that I'm
choosing. If I then change my sheet to have 200 rows and run the macro
the Named Range will still be A1:J38 even though this sheet is A1:J200.

Here is the macro code:

Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
ActiveWorkbook.Names.Add Name:="ARImportFile", RefersToR1C1:= _
"=ARImportFile!R1C1:R38C10"
ActiveWorkbook.Names.Add Name:="ARImportFile", RefersToR1C1:= _
"=ARImportFile!R1C1:R38C10"
Range("A1").Select
End Sub


How can I change the code to make sure the Named Range uses the dynamic
number of rows?

Thanks for your help.
Leanne



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Named Range Into a Cell Tondos Excel Worksheet Functions 2 February 27th 09 06:29 PM
Use CopyFromRecordSet to insert named range formulas? (Excel 2000) Kel Good Excel Programming 5 November 9th 05 06:54 AM
Using ADO to INSERT Named Range Values into DB [email protected] Excel Programming 1 March 24th 05 02:29 PM
INSERT into named range using ADO Tim Payne Excel Programming 3 January 28th 05 09:26 AM
Insert named range problem FinChase Excel Programming 11 November 15th 04 07:21 PM


All times are GMT +1. The time now is 11:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"