Hi All,
I am real new at VBA Macros. Tons of experience in the old Lotus 123 Macros but that was another day and time. My VBA Macro abiltiy is pretty much limited to those that I can record, or find answers for on the web. I am trying to write a macro that I can use to sum columns (diferrent 1's at different times) that have contiguously filled cells above, the number of rows of which may vary. After this section of the Macro is complete I want to continue on with more Macro steps that I have already written. The summations may take place in the same columns at different rows but the data will always be sepearted by blank cells. I am able to accomplish some of this with the following subroutine.
Sub SumCol()
Range("C6:D6").Cells.ClearContents 'This clears the summation formula from prior attempts.
Range("C3").Select 'This selects the top cell to be included in the sum.
Selection.End(xlDown).Select 'This selects C3:C5 (in this case) as the range to be summed.
ActiveCell.Offset(1, 0).Range("A1").Activate 'This makes the cell immediately below the data (C6) active for the sum formula..
Application.CommandBars.ExecuteMso ("AutoSum") 'This enters the formula =sum(C3:C5) in cell C6 (Which is what I want - but it doesn't close off the formula).
Application.SendKeys "{return}" 'The sum formula remained open and all processing stopped until I input this row and the next.
Application.Wait Now + TimeValue("00:00:10") 'Once this row was entered the sum formula closed & I got the right answer, but all further processing stops.
Range("D6").Select 'Without the row above this would become the active cell and =sum(C3:C5) would show up here at D6.
'With the Application.Wait row above all processing of this subroutine halts, never to restart.
ActiveCell.Value = 15 'The rest is just junk code to see if I could make this puppy continue working.
Application.SendKeys "{return}"
Application.Wait Now + TimeValue("0:00:10")
End Sub
SendKeys might be the problem as the Application.Wait doesn't slow the process down even for a second in this Macro. When I put the Application.Wait line in its own subroutine and run that by itself, it pauses Excel for whatever time I assign to it. I am a might bewildered over all this and would really appreciate your help. Thanks!
DMumme
Bookmarks