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 / Bob Phillips if you are out there

I tried to post on the original thread but did not seem to work.

Here it is again:

Here's the code that I am actually using (I changed the cell reference A10
to B19).

Option Explicit
Sub maketable3()
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("b19").End(xlDown).Row
LastCol = .Range("b19").End(xlToRight).Column
Set RngToName = .Range("b19", .Cells(LastRow, LastCol))
RngToName.Name = Application.Range("SheetNames").Cells(I,
1).Value

End With
End If
Next sh
End Sub

Bob asked: When you get the error, hover over the variables LastRow and
LastCol and see what the values are.

LastRow=109 Last Column=6

Bob asked: Also type ?RngToName.Address in the immediate window and see what
it returns.

?RngToName.Address
$B$19:$F$109

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

Nothing. Completely blank.

Thanks again.

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default Macro / Bob Phillips if you are out there

Carl,

Those values look okay. The only other thing to look at is the value being
assigned.

What does

Application.Range("SheetNames").Cells(I, 1).Value

hold at the point of error?

--
HTH

Bob Phillips

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

"carl" wrote in message
...
I tried to post on the original thread but did not seem to work.

Here it is again:

Here's the code that I am actually using (I changed the cell reference A10
to B19).

Option Explicit
Sub maketable3()
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("b19").End(xlDown).Row
LastCol = .Range("b19").End(xlToRight).Column
Set RngToName = .Range("b19", .Cells(LastRow, LastCol))
RngToName.Name = Application.Range("SheetNames").Cells(I,
1).Value

End With
End If
Next sh
End Sub

Bob asked: When you get the error, hover over the variables LastRow and
LastCol and see what the values are.

LastRow=109 Last Column=6

Bob asked: Also type ?RngToName.Address in the immediate window and see

what
it returns.

?RngToName.Address
$B$19:$F$109

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

Nothing. Completely blank.

Thanks 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
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM


All times are GMT +1. The time now is 10:17 PM.

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"