PDA

View Full Version : Excel Macro Code Run without Button Click



r_know
06-24-2012, 12:16 AM
Dear All,

I have VBA Code which works when I HiT the button.Actually, VBA code based on the dates, I am selecting two dates then Hitting button, to get result.

Please advise, how do I get result once enter the only Dates in Two Cells.

I do not want to use the Short-Cut Key for Macro code.



Regards,

Rahul
:help

Aussiebear
06-24-2012, 01:08 AM
What are the conditions? You should know better than to ask a question as vague as the above.

r_know
06-24-2012, 02:30 AM
Conditions very clear,

Date 1 Date 2 BUTTON Result

I want VBA code work, without pressing the BUTTON which having code for result.
Means, How I can configure for DATE Cells which automatically run the Button for same?

Bob Phillips
06-24-2012, 03:09 AM
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Me.Range("Date1"), Target) Is Nothing Or _
Not Intersect(Me.Range("Date2"), Target) Is Nothing Then

If Me.Range("Date1").Value <> "" And Me.Range("Date2").Value <> "" Then

MsgBox Me.Range("Date2").Value - Me.Range("Date1").Value & " days"
End If
End If
End Sub

Aussiebear
06-24-2012, 02:38 PM
I have VBA Code which works when I HiT the button.Actually, VBA code based on the dates, I am selecting two dates then Hitting button, to get result.

Please advise, how do I get result once enter the only Dates in Two Cells.

I do not want to use the Short-Cut Key for Macro code.
The conditions are not clear at all. I will break down your statement piece by piece to indicate why


I have VBA Code which works when I HIT the button Where and what is the code?
Was a sample workbook provided to show what you wanted done?


Actually, VBA code based on the dates Where are the two dates to be found?


I am selecting two dates then Hitting button, to get result. What is the result?


Please advise, how do I get result once enter the only Dates in Two Cells. Where were the two dates being entered?
What result were you looking for?


I do not want to use the Short-Cut Key for Macro code. Finally something clear, but not useful.

In future please supply a sample workbook to enable people to assist you in your request. This will breakdown any confusion that arises from poorly worded descriptions of what a User will think the issue is.