Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default macro that runs when the value in A1 has a certain property

Basic Question: How can I create a macro that tests whether the value in
column C is €œX€ and if it is, run a separate macro.

Detailed Question: At the moment, I have a macro that names the workbook
after a date value in Sheet1!A1. I want my macro to take that value and
search in Sheet2, column A for that date, and then test whether the text
value in column C is €œTue.€ If it is Tue, then I want to copy and paste the
prior weeks numbers into a new worksheet.

Example: The value in Sheet1!A1 is 10-Jan-06 and since that is a Tuesday,
rows 2-Jan-06 to 8-Jan-06 are copied and pasted to a new worksheet. Does
anyone have any ideas how to do that?

Date No. Day
2-Jan-06 281 Mon
3-Jan-06 282 Tue
4-Jan-06 283 Wed
5-Jan-06 284 Thu
6-Jan-06 285 Fri
7-Jan-06 286 Sat
8-Jan-06 287 Sun
9-Jan-06 288 Mon
10-Jan-06 289 Tue
11-Jan-06 290 Wed

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default macro that runs when the value in A1 has a certain property

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1"


On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Call myMacro

End With
End If


ws_exit:
Application.EnableEvents = True
End Sub


'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"redb" wrote in message
...
Basic Question: How can I create a macro that tests whether the value in
column C is "X" and if it is, run a separate macro.

Detailed Question: At the moment, I have a macro that names the workbook
after a date value in Sheet1!A1. I want my macro to take that value and
search in Sheet2, column A for that date, and then test whether the text
value in column C is "Tue." If it is Tue, then I want to copy and paste

the
prior week's numbers into a new worksheet.

Example: The value in Sheet1!A1 is 10-Jan-06 and since that is a Tuesday,
rows 2-Jan-06 to 8-Jan-06 are copied and pasted to a new worksheet. Does
anyone have any ideas how to do that?

Date No. Day
2-Jan-06 281 Mon
3-Jan-06 282 Tue
4-Jan-06 283 Wed
5-Jan-06 284 Thu
6-Jan-06 285 Fri
7-Jan-06 286 Sat
8-Jan-06 287 Sun
9-Jan-06 288 Mon
10-Jan-06 289 Tue
11-Jan-06 290 Wed



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
VBA macro runs fine, but freezes if I try to do ANYTHING else whileit runs Rruffpaw Setting up and Configuration of Excel 1 September 17th 11 01:25 PM
Why macro runs on the same sheet? Harshad[_2_] Excel Discussion (Misc queries) 1 September 15th 08 09:39 AM
One macro runs then it auto runs another macro PG Excel Discussion (Misc queries) 2 September 1st 06 09:30 PM
Which Macro Runs...? Bill Martin Excel Discussion (Misc queries) 7 September 29th 05 12:42 PM
Macro runs in source , but not when in Personal Macro Workbook Darin Kramer Excel Programming 1 September 13th 05 04:48 PM


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

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

About Us

"It's about Microsoft Excel"