Hello,
I found this VBA code that converts a range into a table. It works perfectly fine, my only issue with it is " Set OpenWb = Workbooks.Open("C:\Users\user\Desktop\data.xlsb")". Does this mean that if someone else tries to run this code on their computer it won't work as I set it under my username? If so, is there a way change this to simply refer to a specific worksheet in the current excel file?
I also found this VBA code below as well but the example he used was an excel file with only one worksheet, so it didn't work for me, is there a way to specify exactly what worksheet I want it to run in? I don't know if the code below is better than the above...
Thanks for the help
I found this VBA code that converts a range into a table. It works perfectly fine, my only issue with it is " Set OpenWb = Workbooks.Open("C:\Users\user\Desktop\data.xlsb")". Does this mean that if someone else tries to run this code on their computer it won't work as I set it under my username? If so, is there a way change this to simply refer to a specific worksheet in the current excel file?
VBA Code:
Sub converttbl()
Dim OpenWb As Workbook
Set OpenWb = Workbooks.Open("C:\Users\user\Desktop\data.xlsb")
Dim wsData As Worksheet
Set wsData = OpenWb.Worksheets("Data")
OpenWb.Worksheets("Data").Range("A1").Select
ActiveSheet.ListObjects.Add(xlSrcRange, Selection.CurrentRegion, , xlYes).Name = _
"MyTable"
MsgBox "Execution completed"
End Sub
I also found this VBA code below as well but the example he used was an excel file with only one worksheet, so it didn't work for me, is there a way to specify exactly what worksheet I want it to run in? I don't know if the code below is better than the above...
VBA Code:
Dim src As Range
Dim ws As Worksheet
Set src = Range("B5").CurrentRegion
Set ws = ActiveSheet
ws.ListObjects.Add( SourceType:=xlSrcRange, Source:=src, _
xlListObjectHasHeaders:=xlYes, tablestyleName:="TableStyleMedium28").Name = "Sales_Table"
Thanks for the help