Group:  Microsoft Excel ยป microsoft.public.excel.worksheet.functions
Thread: Macro / Bob Phillips if you are out there

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Macro / Bob Phillips if you are out there
carl 18.09.2006 22:27:01
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.

Re: Macro / Bob Phillips if you are out there
"Bob Phillips" <bob.NGs[ at ]somewhere.com> 18.09.2006 22:50:44
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" <carl[ at ]discussions.microsoft.com> wrote in message
news:BDE5C1FE-9DC4-42F0-9423-6115A1D7D825[ at ]microsoft.com...
[Quoted Text]
> 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.
>


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net