If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Running macro from drop down list.....after update?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-10-08, 20:22
Mike375 Mike375 is offline
Registered User
 
Join Date: Apr 2004
Location: Sydney Australia
Posts: 369
Running macro from drop down list.....after update?

I have very limited experience with Excel and I have been trying to duplicate something I do in Access and the reason being for people who do not have Access.

I am using

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
With Target

to trigger different macros. I have a bunch of If/Then to determine whether a macro will run. My problem with drop down lists (combo box) is that the macro runs when I click the cell but does not run after the selection is made. I need the data that the drop down inserts in the cell.

Also, I was told by a poster on another forum that ActiveCell is not good to use due to reliability. So far I have based a lot of what I am doing on ActiveCell, Target.Column And Target.Row. Does anyone see a problem with these as I am close to the stage of "cleaning up" the screen for a working version.

Thanks for any help.
Reply With Quote
  #2 (permalink)  
Old 12-11-08, 09:51
weejas weejas is offline
Registered User
 
Join Date: Sep 2006
Location: Surrey, UK
Posts: 448
If the macro to be fired is dependant on the value in the combo box, don't trigger it from the worksheet. Use the combo box's OnExit event instead.

I've had no problem using ActiveCell, and I've done so since it was demonstrated to me in 2005.
Reply With Quote
  #3 (permalink)  
Old 12-11-08, 10:07
Mike375 Mike375 is offline
Registered User
 
Join Date: Apr 2004
Location: Sydney Australia
Posts: 369
Quote:
Originally Posted by weejas
If the macro to be fired is dependant on the value in the combo box, don't trigger it from the worksheet. Use the combo box's OnExit event instead.
I've had no problem using ActiveCell, and I've done so since it was demonstrated to me in 2005.
Where do you find it? or are there different ways to make the drop down list.

I put some entries in cells/rows and then to Data/Validate/List and drage down the cells. What I have made only shows the drop down arrow when you click on it. Does that sound right.

If I can get a macro working on after update then that will add heaps of flexibility.
Reply With Quote
  #4 (permalink)  
Old 12-11-08, 10:28
weejas weejas is offline
Registered User
 
Join Date: Sep 2006
Location: Surrey, UK
Posts: 448
It's quite tricky working in the abstract. Do you have a copy of the workbook in question that you could post? If so, I'll take a look when I get home tonight.
Reply With Quote
  #5 (permalink)  
Old 12-11-08, 23:58
Mike375 Mike375 is offline
Registered User
 
Join Date: Apr 2004
Location: Sydney Australia
Posts: 369
I have attached 3 Word docs with it as they have the bookmarks as you will see on the Excel drop down list they are 3 that are referenced

Macro11 is the main one I am playing with and you will see it is referencing on the Sheet1 event.

Basically, I am trying to do in Excel a system I run on Access to produce Word docs and also the saving and retrieving of them and also a back a system I do.....hence you will see in some of the macros the SaveAs type stuff.

My main problem is how to trigger macros etc as you will see from my attempts
Attached Files
File Type: zip AlmostThere.zip (29.8 KB, 154 views)
File Type: zip 0Letter1Mike.zip (3.1 KB, 63 views)
File Type: zip 0Letter2Mike.zip (2.8 KB, 44 views)
File Type: zip 0Letter3Mike.zip (2.9 KB, 52 views)
Reply With Quote
  #6 (permalink)  
Old 12-16-08, 12:02
weejas weejas is offline
Registered User
 
Join Date: Sep 2006
Location: Surrey, UK
Posts: 448
Sorry about the delay in getting back to you. The tail-end of last week was manic.

I've had a look and neatened up the code a bit. I think I know what's going on, but I can see one problem immediately. You've put the master code in the sheet module for Worksheet1 on the SelectionChange event, but you want it to trigger when a value in a cell changes. SelectionChange happens when you move the selection from one cell to another, rather than when a cell changes value. I think that your validated cell (your drop-down list) needs to be replaced with a combo box. Assuming that nothing else goes wrong, I'll have a play tonight and see what comes to mind.
Reply With Quote
  #7 (permalink)  
Old 12-16-08, 17:41
weejas weejas is offline
Registered User
 
Join Date: Sep 2006
Location: Surrey, UK
Posts: 448
I still haven't had a chance to pick through your code and work out what's what. (Comments are you friend, and even more so the friend of those who come after you!) However, one thing struck me when I trawled the help file. If you copy the code from the worksheet's SelectionChange event to the Change event, it will fire after you pick a new value from the validated list. I tried this, and the code fired when a new value was selected.

Have a try and see if it works for you.
Reply With Quote
  #8 (permalink)  
Old 12-16-08, 20:18
Mike375 Mike375 is offline
Registered User
 
Join Date: Apr 2004
Location: Sydney Australia
Posts: 369
You forgot to attach

I have attached my latest and have made some good progress with the combo on the screen via Data/Validat.

It is macro27 behind it.

Basically, I click on the row (any column will do) on the person who will get the letter and then select the letter from the combo. That then takes me back to the row/cell I clicked on and presses on to use the data on the rwo for the bookmarks.

I am still using the drop down list at E25 for the reference, that is where the combo is inserting the name of the Word.doc.

I think the next step I would like to be able to do, if it is posible, is that when clicking on the row that has the person's details that the action then moves the combo to that row. The way I have it at the moment will not be practical if the spread sheet had a 1000 rows. Perhaps I need to use a combo on a form instead and clicking on the row opens the form.

I think a basic problem I have here (apart from being short on knowlege on Excel) is I am trying reproduce something I do in Access but it is an area that falls into Access's strong points but Excels weak points. The reverse would be having a column in Excel with a row of writing every 10 rows and summing the column, that would be a big deal in Access
Attached Files
File Type: zip AlmostThereComboWorking.zip (43.7 KB, 254 views)
Reply With Quote
  #9 (permalink)  
Old 12-17-08, 19:18
Mike375 Mike375 is offline
Registered User
 
Join Date: Apr 2004
Location: Sydney Australia
Posts: 369
I have moved to the form with a combo and have that working and that will eliminate the problem of having a 1000 rows sicne the form will open in the middle of the screen.

The next thing I need to do to duplicate what I di in Access might be a bit hard. In Access, when the letter is run apart from saving the Word doc with a date/time stamp in the file name it also inserts that name in a Many table record for the person. That in turn allows letters to be selected and opened.

At the moment the only way I can thik of approaching that in Excel would be for the name of the Word doc to be saved across the person's row.
Reply With Quote
  #10 (permalink)  
Old 12-26-08, 02:56
karthic_85 karthic_85 is offline
Registered User
 
Join Date: Dec 2007
Posts: 37
Worksheet_Change(ByVal Target As Range) will capture the drop down list change event
& ActiveCell will give u the selected value
__________________
Meyyappan
Reply With Quote
  #11 (permalink)  
Old 12-27-08, 12:05
Mike375 Mike375 is offline
Registered User
 
Join Date: Apr 2004
Location: Sydney Australia
Posts: 369
Quote:
Originally Posted by karthic_85
Worksheet_Change(ByVal Target As Range) will capture the drop down list change event
& ActiveCell will give u the selected value
Using the combo on a form had done the job for me.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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