ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need Help With A Loop To Copy (https://www.excelbanter.com/excel-programming/307209-need-help-loop-copy.html)

vsingler

Need Help With A Loop To Copy
 
I'm just getting started learning Excel VBA and I would
very much appreciate some help with a loop structure that
I've been struggling to write.

Each month, data is imported into an Excel spreadsheet.
Because the number of rows will vary every month, I
thought a loop structure would be a good way to handle
the following procedu

In my spreadsheet template there are 5 columns:
Column A - Contains text
Column B - Contains Date/Time Entries
Columns/Rows C1 & D1 - Contain Formulas for Date
calculations

The steps I'm trying to work through a
1) Start in cell A3
2) Determine if cell is empty
3) If it is not empty, move to range (C1:D1) containing
forumulas
4) Copy range (C1:D1)
5) Move down to C3:D3
6) Paste formulas
7) Move to A4 and repeat
8) Stop when an empty cell in Column A is encountered

I've tried several times, but have come up empty.

Any help would be much appreciated.

Thanks in advance,

Val


Tom Ogilvy

Need Help With A Loop To Copy
 
Sub Tester1()
Dim rng As Range
Set rng = Range(Cells(3, 1), Cells(Rows.Count, 1).End(xlUp))
rng.Offset(0, 2).Resize(, 2).Formula = Range("C1:D1").Formula

End Sub

worked for me.

--
Regards,
Tom Ogilvy



"vsingler" wrote in message
...
I'm just getting started learning Excel VBA and I would
very much appreciate some help with a loop structure that
I've been struggling to write.

Each month, data is imported into an Excel spreadsheet.
Because the number of rows will vary every month, I
thought a loop structure would be a good way to handle
the following procedu

In my spreadsheet template there are 5 columns:
Column A - Contains text
Column B - Contains Date/Time Entries
Columns/Rows C1 & D1 - Contain Formulas for Date
calculations

The steps I'm trying to work through a
1) Start in cell A3
2) Determine if cell is empty
3) If it is not empty, move to range (C1:D1) containing
forumulas
4) Copy range (C1:D1)
5) Move down to C3:D3
6) Paste formulas
7) Move to A4 and repeat
8) Stop when an empty cell in Column A is encountered

I've tried several times, but have come up empty.

Any help would be much appreciated.

Thanks in advance,

Val




vsingler

Need Help With A Loop To Copy
 
Tom --

Thanks so much for your help. It works like the
proverbial charm!

Val


-----Original Message-----
Sub Tester1()
Dim rng As Range
Set rng = Range(Cells(3, 1), Cells(Rows.Count, 1).End

(xlUp))
rng.Offset(0, 2).Resize(, 2).Formula = Range

("C1:D1").Formula

End Sub

worked for me.

--
Regards,
Tom Ogilvy



"vsingler" wrote in

message
...
I'm just getting started learning Excel VBA and I would
very much appreciate some help with a loop structure

that
I've been struggling to write.

Each month, data is imported into an Excel spreadsheet.
Because the number of rows will vary every month, I
thought a loop structure would be a good way to handle
the following procedu

In my spreadsheet template there are 5 columns:
Column A - Contains text
Column B - Contains Date/Time Entries
Columns/Rows C1 & D1 - Contain Formulas for Date
calculations

The steps I'm trying to work through a
1) Start in cell A3
2) Determine if cell is empty
3) If it is not empty, move to range (C1:D1) containing
forumulas
4) Copy range (C1:D1)
5) Move down to C3:D3
6) Paste formulas
7) Move to A4 and repeat
8) Stop when an empty cell in Column A is encountered

I've tried several times, but have come up empty.

Any help would be much appreciated.

Thanks in advance,

Val



.



All times are GMT +1. The time now is 06:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com