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

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
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,215,471
Messages
6,124,998
Members
449,201
Latest member
Lunzwe73

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