Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 361
Default Macro Modification - Bob Philips Are You Out There ?

I use this macro on one of my workbooks and it worked awesome - it creates
tables from selected worksheets and names them according to a list of names.

Asuming that the list is named SheetNames, then

Sub maketable2()
Dim SheetList As Sheets
Dim RngToName As Range
Dim LastRow As Long
Dim LastCol As Long
Dim NameToUse As String
Dim sh As Worksheet
Dim i As Long

Set SheetList = ActiveWindow.SelectedSheets
For Each sh In SheetList
i = i + 1
If Application.Range("SheetNames").Cells(i, 1).Value < "" Then
With sh
LastRow = .Range("a10").End(xlDown).Row
LastCol = .Range("a10").End(xlToRight).Column
Set RngToName = .Range("a10", .Cells(LastRow, LastCol))
RngToName.Name =
Application.Range("SheetNames").Cells(i,1).Value
End With
End If
Next sh
End Sub

I've tried to use this same macro to create another workbook and it it gets
hung up he

RngToName.Name = Application.Range("SheetNames").Cells(i,1).Value

The text that appears when I hover the curser over the line is:

RngToName=<Application-defined or object-defined error

The only difference I can tell between this new workbook and the other
workbook is the "SheetNames".

Any Thoughts ?

Thank you again.


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default Macro Modification - Bob Philips Are You Out There ?

Hi Carlo,

When you get the error, hover over the variables LastRow and LastCol and see
what the values are. Also type

?RngToName.Address in the immediate window and see what it returns.

Finally, what is in A1:A12 in that problem sheet.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"carl" wrote in message
...
I use this macro on one of my workbooks and it worked awesome - it creates
tables from selected worksheets and names them according to a list of

names.

Asuming that the list is named SheetNames, then

Sub maketable2()
Dim SheetList As Sheets
Dim RngToName As Range
Dim LastRow As Long
Dim LastCol As Long
Dim NameToUse As String
Dim sh As Worksheet
Dim i As Long

Set SheetList = ActiveWindow.SelectedSheets
For Each sh In SheetList
i = i + 1
If Application.Range("SheetNames").Cells(i, 1).Value < "" Then
With sh
LastRow = .Range("a10").End(xlDown).Row
LastCol = .Range("a10").End(xlToRight).Column
Set RngToName = .Range("a10", .Cells(LastRow, LastCol))
RngToName.Name =
Application.Range("SheetNames").Cells(i,1).Value
End With
End If
Next sh
End Sub

I've tried to use this same macro to create another workbook and it it

gets
hung up he

RngToName.Name = Application.Range("SheetNames").Cells(i,1).Value

The text that appears when I hover the curser over the line is:

RngToName=<Application-defined or object-defined error

The only difference I can tell between this new workbook and the other
workbook is the "SheetNames".

Any Thoughts ?

Thank you again.




  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 361
Default Macro Modification - Bob Philips Are You Out There ?

Thanks Bob.

I'll try and recall - I won't be able to get the workbook until monday.

I did not mention that the A10 in the code was replaced with B19 - if that
makes a difference.

I think when hobering over the varioables last row/last col the value 65000
and 256 respectively.

I do not think there is any data in A1:A12 although not sure. I'll check that.

Thanks Again.

"Bob Phillips" wrote:

Hi Carlo,

When you get the error, hover over the variables LastRow and LastCol and see
what the values are. Also type

?RngToName.Address in the immediate window and see what it returns.

Finally, what is in A1:A12 in that problem sheet.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"carl" wrote in message
...
I use this macro on one of my workbooks and it worked awesome - it creates
tables from selected worksheets and names them according to a list of

names.

Asuming that the list is named SheetNames, then

Sub maketable2()
Dim SheetList As Sheets
Dim RngToName As Range
Dim LastRow As Long
Dim LastCol As Long
Dim NameToUse As String
Dim sh As Worksheet
Dim i As Long

Set SheetList = ActiveWindow.SelectedSheets
For Each sh In SheetList
i = i + 1
If Application.Range("SheetNames").Cells(i, 1).Value < "" Then
With sh
LastRow = .Range("a10").End(xlDown).Row
LastCol = .Range("a10").End(xlToRight).Column
Set RngToName = .Range("a10", .Cells(LastRow, LastCol))
RngToName.Name =
Application.Range("SheetNames").Cells(i,1).Value
End With
End If
Next sh
End Sub

I've tried to use this same macro to create another workbook and it it

gets
hung up he

RngToName.Name = Application.Range("SheetNames").Cells(i,1).Value

The text that appears when I hover the curser over the line is:

RngToName=<Application-defined or object-defined error

The only difference I can tell between this new workbook and the other
workbook is the "SheetNames".

Any Thoughts ?

Thank you again.





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
how do I email amacro? leo Excel Worksheet Functions 24 August 9th 06 02:47 PM
link to combobox legepe Excel Discussion (Misc queries) 4 July 26th 06 04:45 PM
Search, Copy, Paste Macro in Excel [email protected] Excel Worksheet Functions 0 January 3rd 06 06:51 PM
Editing a simple macro Connie Martin Excel Worksheet Functions 5 November 29th 05 09:19 PM
Macro Modification Help Dmorri254 Excel Worksheet Functions 0 March 4th 05 03:51 PM


All times are GMT +1. The time now is 02:56 AM.

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

About Us

"It's about Microsoft Excel"