TitusandNero
New Member
- Joined
- Mar 17, 2016
- Messages
- 26
Hello (operating on Excel 2007)
Hope someone can help a newbie here. I've set up a userform(named Reports) to run a report from an Excel database(named Data) which will then populate an excel spreadsheet(named By Representative) in the same workbook. On the userform(Reports) I have 3 search parameters in text boxes: Name, date1 and date2. By entering a name and date range and clicking 'run report' I'd like it to open the 'By Representative' spreadsheet and populate it.
The Names on the 'Reports' userform are in a dropdown combobox (named cbRep) and will find its match in column O or 15 in the 'Data' database
The date1 and date2 will find their match in column M or 13 in the 'Data' database. Here's my problem - I'm a newbie and I'm learning as I go. I need your help to complete my coding so that it:
A) Opens the By Representative spreadsheet after the click
B) Matches the value in column O in (Data) with the value in the combobox (cbReP) - can't seem to find the right code
C) Searches between two dates
I'd really appreciate any assistance: Here is my coding so far (which I copied from a youtube video). It is incomplete and obviously not working.
Private Sub CommandButton1_Click()
Dim sdsheet As Worksheet, ersheet As Worksheet
Set sdsheet = ThisWorkbook.sheets ("Data")
set ersheet = ThisWorkbook.Sheets ("By Representative")
If sdsheet.cells(Rows.Count, 1).End(xlUp).row = 1 Then
sdLR = 2
Else
sdLR = sdsheet.Cells(Rows.Count, 1).End(xlUp).Row
End If
y = 2 'starting row
For x = 2 To sdLR
If sdsheet.Cells(y, 1) = "Reports.cbRep" Then **There is an error here. It doesn't like "Reports.cbRep", I've tried different variations but can't seem to get it right**
ersheet.cells (y, 1) = sdsheet.cells (x, 15)
ersheet.Cells (y, 2) = sdsheet.Cells (x, 1)
ersheet.Cells (y, 3) = sdsheet.Cells (x, 10)
etc, etc..
y = y +1
End If
Next x
End Sub
Thanks you
Hope someone can help a newbie here. I've set up a userform(named Reports) to run a report from an Excel database(named Data) which will then populate an excel spreadsheet(named By Representative) in the same workbook. On the userform(Reports) I have 3 search parameters in text boxes: Name, date1 and date2. By entering a name and date range and clicking 'run report' I'd like it to open the 'By Representative' spreadsheet and populate it.
The Names on the 'Reports' userform are in a dropdown combobox (named cbRep) and will find its match in column O or 15 in the 'Data' database
The date1 and date2 will find their match in column M or 13 in the 'Data' database. Here's my problem - I'm a newbie and I'm learning as I go. I need your help to complete my coding so that it:
A) Opens the By Representative spreadsheet after the click
B) Matches the value in column O in (Data) with the value in the combobox (cbReP) - can't seem to find the right code
C) Searches between two dates
I'd really appreciate any assistance: Here is my coding so far (which I copied from a youtube video). It is incomplete and obviously not working.
Private Sub CommandButton1_Click()
Dim sdsheet As Worksheet, ersheet As Worksheet
Set sdsheet = ThisWorkbook.sheets ("Data")
set ersheet = ThisWorkbook.Sheets ("By Representative")
If sdsheet.cells(Rows.Count, 1).End(xlUp).row = 1 Then
sdLR = 2
Else
sdLR = sdsheet.Cells(Rows.Count, 1).End(xlUp).Row
End If
y = 2 'starting row
For x = 2 To sdLR
If sdsheet.Cells(y, 1) = "Reports.cbRep" Then **There is an error here. It doesn't like "Reports.cbRep", I've tried different variations but can't seem to get it right**
ersheet.cells (y, 1) = sdsheet.cells (x, 15)
ersheet.Cells (y, 2) = sdsheet.Cells (x, 1)
ersheet.Cells (y, 3) = sdsheet.Cells (x, 10)
etc, etc..
y = y +1
End If
Next x
End Sub
Thanks you
