Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Subject: clicking on a button copies the choice *(VBA)

Hello folks.
In a sheet, I have a drop down list of Patient IDs. Say cell A1. next to
it, on cell B1, I have a pull-down menue of their specific Disease.
There are about 200 such Patient IDs that I need to assign their disease to.

On a separate sheet, I have a list of about 10,000 patient IDs. What I like
to be able to do is to set up a button that lunches a VBA.
What I want this VBA program to do is look through the 10,000 or so list of
Patient IDs on the second sheet, and find the one that matches the same
Patietn ID that I have selected from my pull down menu on the first sheet and
then copy the disease that I choose from cell B1 in the cell next to that
patient's ID on the second sheet.

I hope I made sense. Basiclly, I need a complete VBA that I can copy and
paste in my code window, assign that click-event button to it and use it.

Essentially, what I want is as I choose a patient ID from cell A1, sheet 1
and assign to this patient is a disease from pull-down menu in B1, sheet 1,
that this disease be copied in front of it correct patient Id (among many
thousands of patient id) on sheet2.

I hope someone can help us out :)

thanks

Thrava

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default Subject: clicking on a button copies the choice *(VBA)

VBA is not needed here, all you need to do is use the VLOOKUP function:
=VLOOKUP(A1,Sheet2!A1:B10000,2)
--
Charles Chickering

"A good example is twice the value of good advice."


"Thrava" wrote:

Hello folks.
In a sheet, I have a drop down list of Patient IDs. Say cell A1. next to
it, on cell B1, I have a pull-down menue of their specific Disease.
There are about 200 such Patient IDs that I need to assign their disease to.

On a separate sheet, I have a list of about 10,000 patient IDs. What I like
to be able to do is to set up a button that lunches a VBA.
What I want this VBA program to do is look through the 10,000 or so list of
Patient IDs on the second sheet, and find the one that matches the same
Patietn ID that I have selected from my pull down menu on the first sheet and
then copy the disease that I choose from cell B1 in the cell next to that
patient's ID on the second sheet.

I hope I made sense. Basiclly, I need a complete VBA that I can copy and
paste in my code window, assign that click-event button to it and use it.

Essentially, what I want is as I choose a patient ID from cell A1, sheet 1
and assign to this patient is a disease from pull-down menu in B1, sheet 1,
that this disease be copied in front of it correct patient Id (among many
thousands of patient id) on sheet2.

I hope someone can help us out :)

thanks

Thrava

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Subject: clicking on a button copies the choice *(VBA)

Private sub CommandButton1_Click()
Dim rng as Range, rng1 as Range
Dim res as Variant
with worksheets("Sheet2")
set rng = .Range(.Cells(2,1),.Cells(rows.count,1).End(xlup))
end with
res = Application.Match(worksheets("Sheet1").Range("A1") ,rng,0)
if not iserror(res) then
set rng1 = rng(res)
rng1.offset(0,1).Value = worksheets("Sheet1").Range("B1").Value
else
msgbox worksheets("Sheet1").Range("A1").Value & " was not " &
vbNewLine & "on sheet2"
end if
End Sub

--
Regards,
Tom Ogilvy



"Thrava" wrote in message
...
Hello folks.
In a sheet, I have a drop down list of Patient IDs. Say cell A1. next to
it, on cell B1, I have a pull-down menue of their specific Disease.
There are about 200 such Patient IDs that I need to assign their disease
to.

On a separate sheet, I have a list of about 10,000 patient IDs. What I
like
to be able to do is to set up a button that lunches a VBA.
What I want this VBA program to do is look through the 10,000 or so list
of
Patient IDs on the second sheet, and find the one that matches the same
Patietn ID that I have selected from my pull down menu on the first sheet
and
then copy the disease that I choose from cell B1 in the cell next to that
patient's ID on the second sheet.

I hope I made sense. Basiclly, I need a complete VBA that I can copy and
paste in my code window, assign that click-event button to it and use it.

Essentially, what I want is as I choose a patient ID from cell A1, sheet 1
and assign to this patient is a disease from pull-down menu in B1, sheet
1,
that this disease be copied in front of it correct patient Id (among many
thousands of patient id) on sheet2.

I hope someone can help us out :)

thanks

Thrava



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Subject: clicking on a button copies the choice *(VBA)

Thanks so much Tom,
I'll give this a shot :)

"Tom Ogilvy" wrote:

Private sub CommandButton1_Click()
Dim rng as Range, rng1 as Range
Dim res as Variant
with worksheets("Sheet2")
set rng = .Range(.Cells(2,1),.Cells(rows.count,1).End(xlup))
end with
res = Application.Match(worksheets("Sheet1").Range("A1") ,rng,0)
if not iserror(res) then
set rng1 = rng(res)
rng1.offset(0,1).Value = worksheets("Sheet1").Range("B1").Value
else
msgbox worksheets("Sheet1").Range("A1").Value & " was not " &
vbNewLine & "on sheet2"
end if
End Sub

--
Regards,
Tom Ogilvy



"Thrava" wrote in message
...
Hello folks.
In a sheet, I have a drop down list of Patient IDs. Say cell A1. next to
it, on cell B1, I have a pull-down menue of their specific Disease.
There are about 200 such Patient IDs that I need to assign their disease
to.

On a separate sheet, I have a list of about 10,000 patient IDs. What I
like
to be able to do is to set up a button that lunches a VBA.
What I want this VBA program to do is look through the 10,000 or so list
of
Patient IDs on the second sheet, and find the one that matches the same
Patietn ID that I have selected from my pull down menu on the first sheet
and
then copy the disease that I choose from cell B1 in the cell next to that
patient's ID on the second sheet.

I hope I made sense. Basiclly, I need a complete VBA that I can copy and
paste in my code window, assign that click-event button to it and use it.

Essentially, what I want is as I choose a patient ID from cell A1, sheet 1
and assign to this patient is a disease from pull-down menu in B1, sheet
1,
that this disease be copied in front of it correct patient Id (among many
thousands of patient id) on sheet2.

I hope someone can help us out :)

thanks

Thrava




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Subject: clicking on a button copies the choice *(VBA)

Hi Charles,
Thank you for taking the time to respond. In this case, unfortunately,
VLookup will not work. It works only for the specific Patient ID that I have
chosen from the pull-down menu. As I assign the disease and choose a second
Patient ID, the vlookup for the previous patient ID will not be retained.



"Charles Chickering" wrote:

VBA is not needed here, all you need to do is use the VLOOKUP function:
=VLOOKUP(A1,Sheet2!A1:B10000,2)
--
Charles Chickering

"A good example is twice the value of good advice."


"Thrava" wrote:

Hello folks.
In a sheet, I have a drop down list of Patient IDs. Say cell A1. next to
it, on cell B1, I have a pull-down menue of their specific Disease.
There are about 200 such Patient IDs that I need to assign their disease to.

On a separate sheet, I have a list of about 10,000 patient IDs. What I like
to be able to do is to set up a button that lunches a VBA.
What I want this VBA program to do is look through the 10,000 or so list of
Patient IDs on the second sheet, and find the one that matches the same
Patietn ID that I have selected from my pull down menu on the first sheet and
then copy the disease that I choose from cell B1 in the cell next to that
patient's ID on the second sheet.

I hope I made sense. Basiclly, I need a complete VBA that I can copy and
paste in my code window, assign that click-event button to it and use it.

Essentially, what I want is as I choose a patient ID from cell A1, sheet 1
and assign to this patient is a disease from pull-down menu in B1, sheet 1,
that this disease be copied in front of it correct patient Id (among many
thousands of patient id) on sheet2.

I hope someone can help us out :)

thanks

Thrava



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Subject: clicking on a button copies the choice *(VBA)

Works like a charm :)
Thanks again

"Tom Ogilvy" wrote:

Private sub CommandButton1_Click()
Dim rng as Range, rng1 as Range
Dim res as Variant
with worksheets("Sheet2")
set rng = .Range(.Cells(2,1),.Cells(rows.count,1).End(xlup))
end with
res = Application.Match(worksheets("Sheet1").Range("A1") ,rng,0)
if not iserror(res) then
set rng1 = rng(res)
rng1.offset(0,1).Value = worksheets("Sheet1").Range("B1").Value
else
msgbox worksheets("Sheet1").Range("A1").Value & " was not " &
vbNewLine & "on sheet2"
end if
End Sub

--
Regards,
Tom Ogilvy



"Thrava" wrote in message
...
Hello folks.
In a sheet, I have a drop down list of Patient IDs. Say cell A1. next to
it, on cell B1, I have a pull-down menue of their specific Disease.
There are about 200 such Patient IDs that I need to assign their disease
to.

On a separate sheet, I have a list of about 10,000 patient IDs. What I
like
to be able to do is to set up a button that lunches a VBA.
What I want this VBA program to do is look through the 10,000 or so list
of
Patient IDs on the second sheet, and find the one that matches the same
Patietn ID that I have selected from my pull down menu on the first sheet
and
then copy the disease that I choose from cell B1 in the cell next to that
patient's ID on the second sheet.

I hope I made sense. Basiclly, I need a complete VBA that I can copy and
paste in my code window, assign that click-event button to it and use it.

Essentially, what I want is as I choose a patient ID from cell A1, sheet 1
and assign to this patient is a disease from pull-down menu in B1, sheet
1,
that this disease be copied in front of it correct patient Id (among many
thousands of patient id) on sheet2.

I hope someone can help us out :)

thanks

Thrava




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
command button that copies and pastes from one list box to another gbpg Excel Discussion (Misc queries) 8 August 21st 07 06:42 AM
clicking on a button copies the choice *(VBA) Thrava Excel Discussion (Misc queries) 1 October 2nd 06 10:42 PM
Get info on toolbar button by clicking on it Spamarrant Excel Programming 0 August 25th 06 01:33 PM
add text to cell by clicking a choice in drop down list Microsoft Sidewinder wheel force feedbac New Users to Excel 1 May 23rd 06 06:46 PM


All times are GMT +1. The time now is 02:52 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"