Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default can't get code to Run

Can anyone help?

I have read up on VB for Excel and written the code below in the 'Thi
workbook' module. I don't know how to make it run. I have entered i
under 'workbook activate' hoping this would be the best way to get i
to definately run.

It is the first time I have done this, hence the code, if not jus
wrong, is probably inelegant at the very least.
i am trying to scan a worksheet called 'OFF-AIR INPUT' and add up al
the values in column 'F' for all rows that have the same date in colum
'C' and the same text string "Bid-up" in column 'D' and the time i
column 'A' in HH:MM:SS is between 08:00:00 (A2) and 01:00:00 (B2).
need to do this for every day of the year (from Week1) and populat
this results in sheet 'BID-UP'.

So is the code correct and if so, how do get it to run?

dupton


Private Sub Workbook_Activate()

RCOUNT = Worksheet("OFF-AI
INPUT").ACTIVE.CELL.SpecialCells(xlLastCell).Row
CCOUNT = 7
For i = 5 To RCOUNT
For j = 3 To CCOUNT
Date = DateAdd("d", 1, "28-12-2004")
If Worksheet("OFF-AIR INPUT").Range("C5:C65536") = Date Then
If Worksheet("OFF-AIR INPUT").Range("A5:A65536")
Worksheet("OFF-AIR INPUT").Range("B2") And Worksheet("OFF-AI
INPUT").Range("A5:A65536") Worksheet("OFF-AIR INPUT").Range("A2"
Then
If Worksheet("OFF-AIR INPUT").Range("D5:D65536") = "BID-UP
Then
Sum = Application.WorksheetFunction.Sum(Worksheet("OFF-AI
INPUT").Range("F5", Range("F5").End(xlDown)))
Worksheet("BID-UP").Cells(i, j) = Sum
End If
End If
End If
Next j
Next i

End Su

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default can't get code to Run

If you are doing what i think you are doing (evaluating one row at a time in
a loop),
start by changing Range("A5:A65536") to either Range("A" & i) or
Cells(i,1).
As written, you are trying to evaluate the entire range each time through
the loop so the conditions are probably never met and the code doesn't
appear to run.

Change Range("C5:C65536") and Range("D5:D65536") as well.

--
George Nicholson

Remove 'Junk' from return address.


"dupton " wrote in message
...
Can anyone help?

I have read up on VB for Excel and written the code below in the 'This
workbook' module. I don't know how to make it run. I have entered it
under 'workbook activate' hoping this would be the best way to get it
to definately run.

It is the first time I have done this, hence the code, if not just
wrong, is probably inelegant at the very least.
i am trying to scan a worksheet called 'OFF-AIR INPUT' and add up all
the values in column 'F' for all rows that have the same date in column
'C' and the same text string "Bid-up" in column 'D' and the time in
column 'A' in HH:MM:SS is between 08:00:00 (A2) and 01:00:00 (B2). I
need to do this for every day of the year (from Week1) and populate
this results in sheet 'BID-UP'.

So is the code correct and if so, how do get it to run?

dupton


Private Sub Workbook_Activate()

RCOUNT = Worksheet("OFF-AIR
INPUT").ACTIVE.CELL.SpecialCells(xlLastCell).Row
CCOUNT = 7
For i = 5 To RCOUNT
For j = 3 To CCOUNT
Date = DateAdd("d", 1, "28-12-2004")
If Worksheet("OFF-AIR INPUT").Range("C5:C65536") = Date Then
If Worksheet("OFF-AIR INPUT").Range("A5:A65536") <
Worksheet("OFF-AIR INPUT").Range("B2") And Worksheet("OFF-AIR
INPUT").Range("A5:A65536") Worksheet("OFF-AIR INPUT").Range("A2")
Then
If Worksheet("OFF-AIR INPUT").Range("D5:D65536") = "BID-UP"
Then
Sum = Application.WorksheetFunction.Sum(Worksheet("OFF-AIR
INPUT").Range("F5", Range("F5").End(xlDown)))
Worksheet("BID-UP").Cells(i, j) = Sum
End If
End If
End If
Next j
Next i

End Sub


---
Message posted from http://www.ExcelForum.com/



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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
copying vba code to a standard code module 1vagrowr Excel Discussion (Misc queries) 2 November 23rd 05 04:00 PM
VBA code delete code but ask for password and unlock VBA protection WashoeJeff Excel Programming 0 January 27th 04 07:07 AM


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