dougmarkham
Active Member
- Joined
- Jul 19, 2016
- Messages
- 252
- Office Version
- 365
- Platform
- Windows
Hi Folks,
I have been given a workbook with 200 worksheets: each ws contains some data that wish to manipulate.
Is it possible with VBA to loop though the worksheets; determine the CurrentRegion; and, create a dynamic table on each data range?
Currently I use the below VBA to create a dynamic table from an unknown range. Would anybody be willing to help me adapt this VBA to create tables on every worksheet within a workbook?
Kind regards,
Doug.
I have been given a workbook with 200 worksheets: each ws contains some data that wish to manipulate.
Is it possible with VBA to loop though the worksheets; determine the CurrentRegion; and, create a dynamic table on each data range?
Currently I use the below VBA to create a dynamic table from an unknown range. Would anybody be willing to help me adapt this VBA to create tables on every worksheet within a workbook?
Code:
Sub DynamicTables()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlManual
Dim sht As Worksheet
Dim rng As Range
Dim StartCell As Range
Dim objTable As ListObject
Worksheets("Sheet1").Activate
ActiveSheet.Range("1:1").Font.Color = vbWhite
Set sht = Worksheets("Sheet1")
Set StartCell = Range("A1")
[COLOR=#006400] 'Select Range[/COLOR]
StartCell.CurrentRegion.Select
Set objTable = ActiveSheet.ListObjects.Add(xlSrcRange, Selection, , xlYes)
objTable.TableStyle = "TableStyleLight8"
With ActiveSheet
.ListObjects(1).Name = "TableName"
.Columns.AutoFit
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.Calculation = xlAutomatic
End Sub
Kind regards,
Doug.