ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If statements with drop down toolbar (https://www.excelbanter.com/excel-programming/340731-if-statements-drop-down-toolbar.html)

periro16[_9_]

If statements with drop down toolbar
 

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


--
periro16
------------------------------------------------------------------------
periro16's Profile: http://www.excelforum.com/member.php...o&userid=26345
View this thread: http://www.excelforum.com/showthread...hreadid=469588


Tom Ogilvy

If statements with drop down toolbar
 
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

--
Regards,
Tom Ogilvy


"periro16" wrote in
message ...

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


--
periro16
------------------------------------------------------------------------
periro16's Profile:

http://www.excelforum.com/member.php...o&userid=26345
View this thread: http://www.excelforum.com/showthread...hreadid=469588





All times are GMT +1. The time now is 04:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com