Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate the range selection dialog box using vba in Excel?

Tags:

excel

vba

I have connected excel with mssql 2008 database and now the data is filled into excel but it is not a table. I want to create a table automatically when the data load.I have used

where xlWs is excel worksheet

Sub CreateTable(ByRef xlWs As Object)
    xlWs.ListObjects.Add(xlSrcRange, , , xlYes).Name = _
        "Table1"
        'No go in 2003
    xlWs.ListObjects("Table1").TableStyle = "TableStyleLight2"
End Subs into excel.

To make the data into table but it does not display any range dialog as it would do if I would create table using GUI. How to display such dialog?

like image 712
kinkajou Avatar asked Feb 03 '23 13:02

kinkajou


1 Answers

You cannot display the built in range dialog, but you can display a dialog box that asks for a range like this:

Dim ThisRng As Range
Set ThisRng = Application.InputBox("Select a range", "Get Range", Type:=8)
like image 108
PaulStock Avatar answered May 11 '23 23:05

PaulStock