Promote Header and create table until last row

xdenama

New Member
Joined
Feb 12, 2016
Messages
39
Office Version
  1. 365
I manually promote header and create a table. How to select all row with MACRO to include in table. Code below is manually drag. How to replace line

Code:
    ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$F$1246"), , xlYes).Name = _

        "PreData"

Macro code

VBA Code:
Sub Macro1()
'
' Macro1 Macro
'

'
    Rows("1:1").Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("A1").Select
    ActiveCell.FormulaR1C1 = "Column1"
    Range("A1").Select
    Selection.AutoFill Destination:=Range("A1:F1"), Type:=xlFillDefault
    Range("A1:F1").Select
    Range("A1:F1").Select
    ' ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$F"), , xlYes).Name =
     '   "Table149"
    ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$F$1246"), , xlYes).Name = _
        "PreData"
    Range("PreData[#All]").Select
    ActiveWindow.ScrollRow = 1213
    ActiveWindow.ScrollRow = 1204
    ActiveWindow.ScrollRow = 1131
    ActiveWindow.ScrollRow = 1101
    ActiveWindow.ScrollRow = 979
    ActiveWindow.ScrollRow = 934
    ActiveWindow.ScrollRow = 833
    ActiveWindow.ScrollRow = 782
    ActiveWindow.ScrollRow = 584
    ActiveWindow.ScrollRow = 514
    ActiveWindow.ScrollRow = 350
    ActiveWindow.ScrollRow = 326
    ActiveWindow.ScrollRow = 250
    ActiveWindow.ScrollRow = 222
    ActiveWindow.ScrollRow = 134
    ActiveWindow.ScrollRow = 98
    ActiveWindow.ScrollRow = 46
    ActiveWindow.ScrollRow = 31
    ActiveWindow.ScrollRow = 1
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
How about
VBA Code:
Sub xdenama()
   Rows(1).Insert
   ActiveSheet.ListObjects.Add(xlSrcRange, Range("A1:F" & Range("A" & Rows.Count).End(xlUp).Row), , xlYes).Name = "PreData"
End Sub
 
Upvote 0
How about
VBA Code:
Sub xdenama()
   Rows(1).Insert
   ActiveSheet.ListObjects.Add(xlSrcRange, Range("A1:F" & Range("A" & Rows.Count).End(xlUp).Row), , xlYes).Name = "PreData"
End Sub
Its working, thank you
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,549
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top