Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am giving myself a crash course in VBA programming using
Walkenbach's book. Hopefully I can figure this out for myself in due time. But as a double-check and perhaps for expediency (learn by example), I would appropriate it if someone would show me a VBA sub (executed using alt-F8) to do the following. I have a worksheet with 10200 daily stock prices (date, open, high, low, close). I want to build worksheet with the last stock prices of each month. (Note: I have good reasons for not simply getting this from Yahoo or other online service.) The pseudocode for the VBA sub that I have in mind is (better ideas are welcomed): ' data is ordered from most recent to oldest date ' skip 1st month (might be partial) lastMonth = month(first cell in selected range) for each cell in selected range if month(cell) < lastMonth then copy 5 contiguous columns (same row) to the right to new row in another (specified) worksheet lastMonth = month(cell) end if next cell Note: Can "selected range" be just the date column, or must it encompass all 5 columns in the 10200 rows? Even if can be just the date column, is there any advantage (in execution time or ease of programming) to encompassing all 5 columns? PS: If you are kind enough to post a prototype VBA, there is no need or expectation to test it. I can do that. I am just hoping for a leg-up on relevant nuances of the VBA language. TIA. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Summing rows based upon condition | Excel Discussion (Misc queries) | |||
Delete Rows based on condition | Excel Discussion (Misc queries) | |||
Copy and Paste based on Condition | Excel Discussion (Misc queries) | |||
Copy Row based on a condition | Excel Worksheet Functions | |||
Create/copy combo boxes in one range if condition is met in a different range | Excel Programming |