PDA

View Full Version : Solved: VB code



lui_roc
03-04-2006, 12:36 PM
Some code was written for me a few weeks back. The problem is, I would like to make a small change but don't know how

A module (module 1) was written for me to import data from another worksheet. The module is activated when a source is selected in column A from a list (ProjectRegister worksheet). The only problem is when a source is deleted (not the whole row, but just the cell contents) to change the name it imports more data.

can anybody help

thanks

Lui

XLGibbs
03-04-2006, 02:03 PM
Hi Lui...the code on that sheet is activated when any change is made in column A by design. When the drop down is changed, it tells it to run the subroutine to import data...

If you change the name in column A, it would seem that this is what you want to happen on the project register.

How do you need it changed?

lui_roc
03-04-2006, 02:21 PM
I have added a new command button "Add Action" that repeats the line above. If the line above has a source name it is deleted because the new line is part of that source. The problem occurs when the source name is deleted, it seems to import lines as soon as the field becomes blank.

If you delete a source name for example cell A12 it adds new data. I don't want this to happen

XLGibbs
03-04-2006, 03:39 PM
I am still not clear on what you need to have happen. You have a button that adds the name from the line above, yet then deletes the line above. Both changes cause the change event to fire and call the import of new data.

If you don't want the import to happen, be sure to disable events within your button click code

Application.EnableEvents = False

then turn them back on to True when the click routine is done.

That should stop the extra action from happening.

malik641
03-04-2006, 04:55 PM
I think this is what you want:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or Target.Cells(1, 1) = "" Then Exit Sub
If Target.Column = 1 Then
Enables False
GetRisks Target
End If
Enables True
End Sub

Right???

lui_roc
03-05-2006, 12:43 AM
Yes - that's exactly what I wanted. thank you both

On a different issue, how do you mark a thread as solved?

johnske
03-05-2006, 12:54 AM
... how do you mark a thread as solved?Hi Lui,

Sorry, at the present moment you can't, the board is in the process of being upgraded and that option's temporarily unavailable - I'll do it for you.

Regards,
John :)

malik641
03-05-2006, 01:04 AM
Yes - that's exactly what I wanted. thank you both

:thumb Good.


John, how do you mark the threads solved manually?

johnske
03-05-2006, 01:46 AM
:thumb Good.


John, how do you mark the threads solved manually?Go to thread tools, select 'Edit Thread' - this brings up the title, then just type in "Solved: " (Should be the same for Mods)

Regards,
John :)

malik641
03-05-2006, 07:53 AM
Go to thread tools, select 'Edit Thread' - this brings up the title, then just type in "Solved: " (Should be the same for Mods)

Regards,
John :)
Thanks buddy :thumb