P
PokerDude
Hi All:
I am trying to create code that when a command button is pressed, it will
open a workbook, copy the data and close the workbook. Then paste the data
in the current workbook and fill a combobox. I am receiving an error with
ActiveSheet.Range(Cells(1, 1), Cells(numRows, 35)) .Copy .Range ("A1").
What am I doing wrong?
Private Sub CommandButton1_Click()
Dim numRows As Long
Workbooks.Open Filename:="c:\CCF\Contracts1.xls"
With ThisWorkbook.Worksheets("Sheet1")
'*** Determine number of rows ***
numRows = Application.CountA(ActiveSheet.Range("A:A"))
'*** The number of columns will always be a static 35 (i.e. A:AI) **
ActiveSheet.Range(Cells(1, 1), Cells(numRows, 35)) .Copy .Range
("A1")
.ComboBox1.ListFillRange = .cells(1,1),.cells(numrows,35)
.ComboBox1.ListIndex = 0
End With
ActiveWorkbook.Close
End Sub
I am trying to create code that when a command button is pressed, it will
open a workbook, copy the data and close the workbook. Then paste the data
in the current workbook and fill a combobox. I am receiving an error with
ActiveSheet.Range(Cells(1, 1), Cells(numRows, 35)) .Copy .Range ("A1").
What am I doing wrong?
Private Sub CommandButton1_Click()
Dim numRows As Long
Workbooks.Open Filename:="c:\CCF\Contracts1.xls"
With ThisWorkbook.Worksheets("Sheet1")
'*** Determine number of rows ***
numRows = Application.CountA(ActiveSheet.Range("A:A"))
'*** The number of columns will always be a static 35 (i.e. A:AI) **
ActiveSheet.Range(Cells(1, 1), Cells(numRows, 35)) .Copy .Range
("A1")
.ComboBox1.ListFillRange = .cells(1,1),.cells(numrows,35)
.ComboBox1.ListIndex = 0
End With
ActiveWorkbook.Close
End Sub