Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Macro formatting

Could someone please help with a macro or any other suggestion to format an
Excel sheet. Basically data is downloaded from a bank every week and the
size of the file can vary but the formatting is constant. That is each
record is 7 lines. So first record is line1-7, second record is line 8-14,
third record is line 15-21 and so on.

I need to format this data and basically I can record a macro for one data
set that is for the record on line 1 to 7. My question is how can I set it
to replicate so that it replicates for line 8-14 and then 15-21 and so on.
The source formatting remains the same except that the total length of the
file( no of records) changes every week.


Thanks very much for your help.

Regards

Sam



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Macro formatting

Hi
This will copy the first seven rows in columns A and B down through the
column

Sub Macro1()
Dim myRange As Range
Dim myRangeRowCount As Long
Dim i As Long

Application.ScreenUpdating = False

Set myRange = Range("A1").CurrentRegion
myRangeRowCount = myRange.Rows.Count 'a multiple of 7
Range("A1:B7").Copy
For i = 1 To myRangeRowCount \ 7 - 1
Range("A1").Offset(7 * i, 0).PasteSpecial Paste:=xlPasteFormats, _
Operation:=xlNone, SkipBlanks:=False,
Transpose:=False
Next i
End Sub

Your data is assumed to start in A1. Change the "A1:B7" to your data
range in the first 7 rows.
regards
Paul

Sam Commar wrote:

Could someone please help with a macro or any other suggestion to format an
Excel sheet. Basically data is downloaded from a bank every week and the
size of the file can vary but the formatting is constant. That is each
record is 7 lines. So first record is line1-7, second record is line 8-14,
third record is line 15-21 and so on.

I need to format this data and basically I can record a macro for one data
set that is for the record on line 1 to 7. My question is how can I set it
to replicate so that it replicates for line 8-14 and then 15-21 and so on.
The source formatting remains the same except that the total length of the
file( no of records) changes every week.


Thanks very much for your help.

Regards

Sam


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Macro formatting

Paul

I tried running it but get a compile error for

Range("A1").Offset(6 * i, 0).PasteSpecial Paste:=xlPasteFormats, _
Operation:=xlNone, SkipBlanks:=False,


As my range is A1 to P6 for each record here is the macro that I created.
(Sorry each record is 6 lines and not 7)


Sub Macro1()
Dim myRange As Range
Dim myRangeRowCount As Long
Dim i As Long

Application.ScreenUpdating = False

Set myRange = Range("A1").CurrentRegion
myRangeRowCount = myRange.Rows.Count 'a multiple of 7
Range("A1:P6").Copy
For i = 1 To myRangeRowCount \ 6 - 1
Range("A1").Offset(6 * i, 0).PasteSpecial Paste:=xlPasteFormats, _
Operation:=xlNone, SkipBlanks:=False,
Transpose:=False
Next i
End Sub


wrote in message
oups.com...
Hi
This will copy the first seven rows in columns A and B down through the
column

Sub Macro1()
Dim myRange As Range
Dim myRangeRowCount As Long
Dim i As Long

Application.ScreenUpdating = False

Set myRange = Range("A1").CurrentRegion
myRangeRowCount = myRange.Rows.Count 'a multiple of 7
Range("A1:B7").Copy
For i = 1 To myRangeRowCount \ 7 - 1
Range("A1").Offset(7 * i, 0).PasteSpecial Paste:=xlPasteFormats, _
Operation:=xlNone, SkipBlanks:=False,
Transpose:=False
Next i
End Sub

Your data is assumed to start in A1. Change the "A1:B7" to your data
range in the first 7 rows.
regards
Paul

Sam Commar wrote:

Could someone please help with a macro or any other suggestion to format
an
Excel sheet. Basically data is downloaded from a bank every week and the
size of the file can vary but the formatting is constant. That is each
record is 7 lines. So first record is line1-7, second record is line
8-14,
third record is line 15-21 and so on.

I need to format this data and basically I can record a macro for one
data
set that is for the record on line 1 to 7. My question is how can I set
it
to replicate so that it replicates for line 8-14 and then 15-21 and so
on.
The source formatting remains the same except that the total length of
the
file( no of records) changes every week.


Thanks very much for your help.

Regards

Sam




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Macro formatting

Hi
Still works for me. The only thing I can think of is that when you
break a line of code, you need to end the first line with "Space
underscore" to continue the line
e.g.
Range("A1").Offset(6 * i, 0).PasteSpecial Paste:=xlPasteFormats, _
Operation:=xlNone, SkipBlanks:=False, _

Transpose:=False

and NOT
Range("A1").Offset(6 * i, 0).PasteSpecial Paste:=xlPasteFormats,
Operation:=xlNone, SkipBlanks:=False,

Transpose:=False

See if that is your problem. Alternatively, don't break the line.
regards
Paul

Sam Commar wrote:

Paul

I tried running it but get a compile error for

Range("A1").Offset(6 * i, 0).PasteSpecial Paste:=xlPasteFormats, _
Operation:=xlNone, SkipBlanks:=False,


As my range is A1 to P6 for each record here is the macro that I created.
(Sorry each record is 6 lines and not 7)


Sub Macro1()
Dim myRange As Range
Dim myRangeRowCount As Long
Dim i As Long

Application.ScreenUpdating = False

Set myRange = Range("A1").CurrentRegion
myRangeRowCount = myRange.Rows.Count 'a multiple of 7
Range("A1:P6").Copy
For i = 1 To myRangeRowCount \ 6 - 1
Range("A1").Offset(6 * i, 0).PasteSpecial Paste:=xlPasteFormats, _
Operation:=xlNone, SkipBlanks:=False,
Transpose:=False
Next i
End Sub


wrote in message
oups.com...
Hi
This will copy the first seven rows in columns A and B down through the
column

Sub Macro1()
Dim myRange As Range
Dim myRangeRowCount As Long
Dim i As Long

Application.ScreenUpdating = False

Set myRange = Range("A1").CurrentRegion
myRangeRowCount = myRange.Rows.Count 'a multiple of 7
Range("A1:B7").Copy
For i = 1 To myRangeRowCount \ 7 - 1
Range("A1").Offset(7 * i, 0).PasteSpecial Paste:=xlPasteFormats, _
Operation:=xlNone, SkipBlanks:=False,
Transpose:=False
Next i
End Sub

Your data is assumed to start in A1. Change the "A1:B7" to your data
range in the first 7 rows.
regards
Paul

Sam Commar wrote:

Could someone please help with a macro or any other suggestion to format
an
Excel sheet. Basically data is downloaded from a bank every week and the
size of the file can vary but the formatting is constant. That is each
record is 7 lines. So first record is line1-7, second record is line
8-14,
third record is line 15-21 and so on.

I need to format this data and basically I can record a macro for one
data
set that is for the record on line 1 to 7. My question is how can I set
it
to replicate so that it replicates for line 8-14 and then 15-21 and so
on.
The source formatting remains the same except that the total length of
the
file( no of records) changes every week.


Thanks very much for your help.

Regards

Sam



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
Formatting for a Macro Maggie Excel Discussion (Misc queries) 3 February 28th 07 02:00 AM
Formatting via a macro mike_vr Excel Discussion (Misc queries) 3 November 8th 06 04:19 PM
Macro Formatting? Please Help Plasmaticfire[_2_] Excel Programming 1 August 11th 06 08:00 PM
formatting macro Greg Brow Excel Programming 1 February 16th 05 10:36 AM
Formatting macro jbb16x99 Excel Programming 3 October 10th 03 10:22 PM


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