如何selectexcel单元格只有字母表跟着?

我正在写的VBA脚本,select单元格范围在Excel表中,但它select在这种格式$ G $ 1:$ K $ 1,但我只需要这种格式$ G:$ K消除数字,而select或任何其他方法消除数字后面$ 。

Sub vloos() Dim rnge As Range Dim Rng As Range Dim user As String Dim file As String file = "E:\output4.xls" Workbooks.Add ActiveWorkbook.SaveAs file Set nb = Application.Workbooks.Open(file) Set ns = nb.Worksheets("Sheet1") 'get workbook path filename = Application.GetOpenFilename(FileFilter:="Excel Files (*.xlsx), *.xls", Title:="Please select a file") 'set our workbook and open it Set wb = Application.Workbooks.Open(filename) 'set our worksheet Set ws = wb.Worksheets("Sheet1") 'set the range for vlookup On Error GoTo En Set rnge = Application.InputBox(Prompt:="Range to format:", Title:="Format Range", Type:=8) Set Rng = ws.Range(rnge.Address) MsgBox Rng.Address En: End Sub 

您可以使用Range对象的EntireColumn属性来获取列

 On Error GoTo En Set rnge = Application.InputBox(Prompt:="Range to format:", Title:="Format Range", Type:=8) Set Rng = rnge.EntireColumn MsgBox Rng.Address