LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Create a list of unallocated payments

Option Explicit

Private Sub Worksheet_Activate()
'by Mike Fogleman Oct 9, 2005
Dim LRow As Long, Lrow2 As Long
Dim rng As Range, rng2 As Range, c As Range

'The next 4 lines deal with sheet "UAllocatedCalcs"
'because Excel assumes code to be run on the active sheet
'unless told differently. This sheet must be active for
'the code to run by definition of the Worksheet_Activate event.

LRow = Cells(Rows.Count, "A").End(xlUp).Row 'finds last row
'with data in col A
If LRow = 3 Then LRow = 4 'if only Header exists start on next row
Set rng = Range("A4:B" & LRow) 'define existing data range
rng.Cells.Clear 'clear the range for new data

'Here we tell Excel to run code on a sheet that is not active
'by using a reference to the worksheet. Again we find the Last
'row in col A and define the range of data to analyze starting
'at row 6.

Lrow2 = Worksheets("CRJournal").Cells(Rows.Count, "A").End(xlUp).Row
Set rng2 = Worksheets("CRJournal").Range("A6:A" & Lrow2)

'We now loop down rng2 (Col A)1 cell at a time and evaluate
'the second cell to the right (Offset)if it is Blank ("")
'If True, then it runs the code following THEN
'If False, then it will skip to End If and loop to next cell.
For Each c In rng2
If c.Offset(0, 2).Value = "" Then
'each time we add data to "UAllocatedCalcs" we need to find
'the last row again and add 1 for the next row.
LRow = Cells(Rows.Count, "A").End(xlUp).Row + 1
'this makes "A next row" = the current cell in the loop
Range("A" & LRow).Value = c.Value
'this makes "B next row" = 1 cell to right of current cell in loop
Range("B" & LRow).Value = c.Offset(0, 1).Value
'formats for 2 decimal places
Range("B" & LRow).NumberFormat = "0.00"
End If
Next c 'loop back to line: For Each c In rng2
End Sub


This should fix the start positions and explain how it does it.
Watch for word wrapping when you paste the code, it should show up red.
Mike F
"mikeburg" wrote in
message ...

The VBA code looks great. That's what I need because we work this sheet
every day. However, I am so new to VBA I am having trouble
understanding it. I need to modify it to:

CRJournal's data starts on row A6

and

UAllocatedCalcs list needs to start on row A4

Can you help me make the modification & maybe comment the code to help
me learn from it? Thanks a million. mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile:
http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=474481



 
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
Constant loan payments vs. constant payments of principal lalli945 Excel Worksheet Functions 3 December 20th 06 10:33 PM
How to create adress list so can mail merge and create labels? adecocq Excel Discussion (Misc queries) 2 October 25th 06 12:32 AM
how do I set up a customer list to track payments pat New Users to Excel 1 January 16th 06 08:10 PM
Does Excel 2002 have a List>Create List option under Data? Jesse Excel Discussion (Misc queries) 3 May 20th 05 01:52 PM
How do I forecast future payments by analyzing past payments? CeeBee Excel Worksheet Functions 1 March 17th 05 06:43 PM


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