If statements with drop down toolbar

P

periro16

The following code does the following:

Users selects/opens a file-> data from the selected file gets copied to
the data in the source worksheet/file


Sub test()
Dim file_open As Variant
Dim WB As Workbook
file_open = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
Set WB = Workbooks.Open(Filename:=file_open)


With ThisWorkbook.Worksheets("Review Schedule & Metrics")
' read data from the source workbook
..Range("A10").Formula = WB.Worksheets("PM").Range("A10").Formula
End With


WB.Close False ' close the source workbook without saving any changes
Set WB = Nothing ' free memory
Application.ScreenUpdating = True ' turn on the screen updating
End Sub



PROPOSED:

1. Add a dropdown toolbar box where users can select an item (total of
6 items)
2. Each item in the list refers to a different set of data (i.e
different range)
3. Depending on what item is selected, the code should go to the
specified range for that item and copy over the data (as what is
happening at the moment anyway)

For example:

If user selects item 1, this will copy over range A10 - A20.

If user selects item 2, this will copy over range A99 - A49..

etc


I am not sure of how i will be using the IF statements and making
references to items in the drop down toolbar button?

Many thanks in advance
 
T

Tom Ogilvy

for i = 0 to Combobox1.Listcount - 1
if Combobox1.Selected(i) then
sName = Combobox1.List(i)
' not sure what is in the combobox dropdown, so . . .
end if
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top