ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Macro Modification (https://www.excelbanter.com/excel-worksheet-functions/141616-macro-modification.html)

Carl

Macro Modification
 
I use this macro to make tables (named ranges).

How can I modify the macro so that it will set the range to A1:I1000 ?

Thanks In Advance.

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("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




All times are GMT +1. The time now is 06:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com