Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Simple macro problem


Im creating a system as part of a school project.
I have this drop down list.
'[image: http://img35.imageshack.us/img35/825...wnlist3zs.jpg]
(http://imageshack.us)
The product codes (C001 etc) are in written in a cells which are no
hidden and i have used a VLOOKUP so the description from another shee
(ProductList) shows the description of each product when select.
Now i have this box on the same sheet as the drop down list.
'[image: http://img5.imageshack.us/img5/4425/productbox5im.jpg]
(http://imageshack.us)
Basically i need a macro which i can attach to a button so that when
product is selected i can click "Add to Order" and it appears in th
box and then i select another product and it does the same thing.
I hope i have made myself clear.
Grateful for any help.
Luke

--
Luke
-----------------------------------------------------------------------
Lukey's Profile: http://www.excelforum.com/member.php...fo&userid=3051
View this thread: http://www.excelforum.com/showthread.php?threadid=50168

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Simple macro problem

Perfectly clear except for any type of detail that might support providing
an answer.

Some assumptions

C002 is located in Cell B2 of Sheet1
Qty will be in cell C2 of Sheet1

the hidden rows of data for the Vlookup are in Sheet1, Cells( A101:F500).
In that range,
Product code is in column A
Description in column B
Price in column C

your order summary is on Sheet2 with the first product code for the first
item in cell F5 and you have allowed 10 rows for products


Assuming a CommandButton from the controls toolbox toolbar. After you add
the button (and still in design mode), double click on it or right click on
it and select view code - takes you to the code module for the sheet with
the declaration:

Private Sub CommandButton1_Click()
Dim rng as Range, res as Variant, cnt as Long
set rng = Worksheets("Sheet2").Range("F5")
cnt = Application.CountA(rng.resize(10,1))
if cnt 9 then
msgbox "Bad design, Out of room"
exit sub
end if
res = Application.Match(Range("Sheet1!B2"),Range("Sheet1 !A101:F500"),0)
if not iserror(res) then
rng.offset(cnt,0).Value = Range("Sheet1!A101")(res,1)
rng.offset(cnt,1).Value = Range("Sheet1!A101")(res,2)
rng.offset(cnt,2).value = Range("Sheet1!A101")(res,3)
rng.offset(cn,3).Value = Range("Sheet1!C2").Value
rng.offset(cnt,4).Value = rng.offset(cnt,2).Value * rng.offset(cnt,3).Value
Else
msgbox "Invalid Product Code"
end if
End Sub

--
Regards,
Tom Ogilvy



"Lukey" wrote in
message ...

Im creating a system as part of a school project.
I have this drop down list.
'[image: http://img35.imageshack.us/img35/8254/dropdownlist3zs.jpg]'
(http://imageshack.us)
The product codes (C001 etc) are in written in a cells which are now
hidden and i have used a VLOOKUP so the description from another sheet
(ProductList) shows the description of each product when select.
Now i have this box on the same sheet as the drop down list.
'[image: http://img5.imageshack.us/img5/4425/productbox5im.jpg]'
(http://imageshack.us)
Basically i need a macro which i can attach to a button so that when a
product is selected i can click "Add to Order" and it appears in the
box and then i select another product and it does the same thing.
I hope i have made myself clear.
Grateful for any help.
Lukey


--
Lukey
------------------------------------------------------------------------
Lukey's Profile:

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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Really simple macro problem - I bet! mrmnz New Users to Excel 2 January 21st 10 11:08 AM
Simple problem, simple formula, no FUNCTION ! Ron@Buy Excel Worksheet Functions 6 September 28th 07 04:51 PM
Simple IF problem Old Timer Excel Discussion (Misc queries) 1 November 7th 06 02:11 AM
Help simple problem [email protected] Excel Programming 1 December 21st 05 09:21 PM
A simple problem... Chris Gorham[_3_] Excel Programming 2 December 24th 03 02:47 PM


All times are GMT +1. The time now is 02:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"