Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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



.

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
compare cells, copy, loop Immortal_Creations Excel Worksheet Functions 2 July 17th 09 03:34 PM
VBA Loop to Find then Copy & Paste B J Hankinson Excel Discussion (Misc queries) 0 April 15th 09 06:39 PM
Find and Copy loop problem BillyJ Excel Discussion (Misc queries) 3 November 2nd 05 07:16 PM
copy and paste loop Dillonstar[_5_] Excel Programming 1 December 11th 03 04:22 PM
search & copy with loop Don Guillett[_4_] Excel Programming 0 July 24th 03 02:55 PM


All times are GMT +1. The time now is 11:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"