Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
HJ HJ is offline
external usenet poster
 
Posts: 28
Default Code assistance needed

I would like to create a macro that looks at cell B18, if there is data in
that cell, then copy that data to range A18:A68, then skip 52 rows and look
at cell B70, if there is data in that cell, then copy that data to range
B70:B120, then skip 52 rows and repeat until there is no data in the cell.

Can someone assist with that code? I have recorded a macro to accomplish
this in the past but now the spreadsheet I have doesn't have a set number of
rows anymore. I don't think that recording it will assure that I will always
pick up all data if rows are added.

Thanks again for your help.

HJ
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Code assistance needed

try the following code (need some modification):

Sub CopyPasteData()
Dim rngSource As Range, rngDestination As Range
Dim rngAll As Range, rr As Integer, MaxRow As Integer

Set rngAll = ActiveSheet.UsedRange
MaxRow = rngAll.Rows.Count + rngAll(1, 1).Row
Application.ScreenUpdating = False
Set rngSource = Range("A18")
rr = rngSource.Row
While rr <= MaxRow
If rngSource < "" Then
Set rngDestination = Range(rngSource, rngSource.Offset(50, 0))
rngSource.Copy Destination:=rngDestination
Set rngSource = rngSource.Offset(52, 0)
rr = rngSource.Row
End If
Wend
Application.ScreenUpdating = True
End Sub

===== * ===== * ===== * =====
Daniel CHEN


www.Geocities.com/UDQServices
Free Data Processing Add-in<

===== * ===== * ===== * =====

"HJ" wrote in message
...
I would like to create a macro that looks at cell B18, if there is data in
that cell, then copy that data to range A18:A68, then skip 52 rows and
look
at cell B70, if there is data in that cell, then copy that data to range
B70:B120, then skip 52 rows and repeat until there is no data in the cell.

Can someone assist with that code? I have recorded a macro to accomplish
this in the past but now the spreadsheet I have doesn't have a set number
of
rows anymore. I don't think that recording it will assure that I will
always
pick up all data if rows are added.

Thanks again for your help.

HJ



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default Code assistance needed

Try the following Macro

Sub Test2()
Dim i%
i = 1
With Sheet1
Do While .Cells(18 + 52 * (i - 1), 2).Value < ""
With .Range(.Cells(18 + 52 * (i - 1), 1), .Cells(18 + 52 * (i)
- 1, 1))
.Value = Sheet1.Cells(18 + 52 * (i - 1), 2).Value
End With
i = i + 1
Loop
End With
End Sub


Alok Joshi

"HJ" wrote:

I would like to create a macro that looks at cell B18, if there is data in
that cell, then copy that data to range A18:A68, then skip 52 rows and look
at cell B70, if there is data in that cell, then copy that data to range
B70:B120, then skip 52 rows and repeat until there is no data in the cell.

Can someone assist with that code? I have recorded a macro to accomplish
this in the past but now the spreadsheet I have doesn't have a set number of
rows anymore. I don't think that recording it will assure that I will always
pick up all data if rows are added.

Thanks again for your help.

HJ

  #4   Report Post  
Posted to microsoft.public.excel.programming
HJ HJ is offline
external usenet poster
 
Posts: 28
Default Code assistance needed

I can't seem to get this to work. When I ran it the first time it was
copying the wrong information. My computer froze so I needed to restart and
I can't get it to work again to tell you which information it was copying.

"Alok" wrote:

Try the following Macro

Sub Test2()
Dim i%
i = 1
With Sheet1
Do While .Cells(18 + 52 * (i - 1), 2).Value < ""
With .Range(.Cells(18 + 52 * (i - 1), 1), .Cells(18 + 52 * (i)
- 1, 1))
.Value = Sheet1.Cells(18 + 52 * (i - 1), 2).Value
End With
i = i + 1
Loop
End With
End Sub


Alok Joshi

"HJ" wrote:

I would like to create a macro that looks at cell B18, if there is data in
that cell, then copy that data to range A18:A68, then skip 52 rows and look
at cell B70, if there is data in that cell, then copy that data to range
B70:B120, then skip 52 rows and repeat until there is no data in the cell.

Can someone assist with that code? I have recorded a macro to accomplish
this in the past but now the spreadsheet I have doesn't have a set number of
rows anymore. I don't think that recording it will assure that I will always
pick up all data if rows are added.

Thanks again for your help.

HJ

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Code assistance needed

for i = 18 to 65536 step 52
if cells(i,2).Value = "" then exit sub
cells(i,1).Resize(50).Value _
= cells(i,2).value
end if
Next


Your example had the destination moving from left to right by column. I
assumed that was a mistake and you wanted them in column A. If not

j = 1
for i = 18 to 65536 step 52
if cells(i,2).Value = "" then exit sub
cells(i,j).Resize(50).Value _
= cells(i,2).value
j = j + 1
if j 256 then
msgbox "Out of columns"
exit sub
end if
end if
Next

--
Regards,
Tom Ogilvy


"HJ" wrote in message
...
I can't seem to get this to work. When I ran it the first time it was
copying the wrong information. My computer froze so I needed to restart

and
I can't get it to work again to tell you which information it was copying.

"Alok" wrote:

Try the following Macro

Sub Test2()
Dim i%
i = 1
With Sheet1
Do While .Cells(18 + 52 * (i - 1), 2).Value < ""
With .Range(.Cells(18 + 52 * (i - 1), 1), .Cells(18 + 52 *

(i)
- 1, 1))
.Value = Sheet1.Cells(18 + 52 * (i - 1), 2).Value
End With
i = i + 1
Loop
End With
End Sub


Alok Joshi

"HJ" wrote:

I would like to create a macro that looks at cell B18, if there is

data in
that cell, then copy that data to range A18:A68, then skip 52 rows and

look
at cell B70, if there is data in that cell, then copy that data to

range
B70:B120, then skip 52 rows and repeat until there is no data in the

cell.

Can someone assist with that code? I have recorded a macro to

accomplish
this in the past but now the spreadsheet I have doesn't have a set

number of
rows anymore. I don't think that recording it will assure that I will

always
pick up all data if rows are added.

Thanks again for your help.

HJ





  #6   Report Post  
Posted to microsoft.public.excel.programming
HJ HJ is offline
external usenet poster
 
Posts: 28
Default Code assistance needed

Thanks Tom. I tried your code and am getting an end if without block if error.

"Tom Ogilvy" wrote:

for i = 18 to 65536 step 52
if cells(i,2).Value = "" then exit sub
cells(i,1).Resize(50).Value _
= cells(i,2).value
end if
Next


Your example had the destination moving from left to right by column. I
assumed that was a mistake and you wanted them in column A. If not

j = 1
for i = 18 to 65536 step 52
if cells(i,2).Value = "" then exit sub
cells(i,j).Resize(50).Value _
= cells(i,2).value
j = j + 1
if j 256 then
msgbox "Out of columns"
exit sub
end if
end if
Next

--
Regards,
Tom Ogilvy


"HJ" wrote in message
...
I can't seem to get this to work. When I ran it the first time it was
copying the wrong information. My computer froze so I needed to restart

and
I can't get it to work again to tell you which information it was copying.

"Alok" wrote:

Try the following Macro

Sub Test2()
Dim i%
i = 1
With Sheet1
Do While .Cells(18 + 52 * (i - 1), 2).Value < ""
With .Range(.Cells(18 + 52 * (i - 1), 1), .Cells(18 + 52 *

(i)
- 1, 1))
.Value = Sheet1.Cells(18 + 52 * (i - 1), 2).Value
End With
i = i + 1
Loop
End With
End Sub


Alok Joshi

"HJ" wrote:

I would like to create a macro that looks at cell B18, if there is

data in
that cell, then copy that data to range A18:A68, then skip 52 rows and

look
at cell B70, if there is data in that cell, then copy that data to

range
B70:B120, then skip 52 rows and repeat until there is no data in the

cell.

Can someone assist with that code? I have recorded a macro to

accomplish
this in the past but now the spreadsheet I have doesn't have a set

number of
rows anymore. I don't think that recording it will assure that I will

always
pick up all data if rows are added.

Thanks again for your help.

HJ




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Code assistance needed

My bad

for i = 18 to 65536 step 52
if cells(i,2).Value = "" then exit sub
cells(i,1).Resize(50).Value _
= cells(i,2).value
Next

--
Regards,
Tom Ogilvy



"HJ" wrote in message
...
Thanks Tom. I tried your code and am getting an end if without block if

error.

"Tom Ogilvy" wrote:

for i = 18 to 65536 step 52
if cells(i,2).Value = "" then exit sub
cells(i,1).Resize(50).Value _
= cells(i,2).value
end if
Next


Your example had the destination moving from left to right by column. I
assumed that was a mistake and you wanted them in column A. If not

j = 1
for i = 18 to 65536 step 52
if cells(i,2).Value = "" then exit sub
cells(i,j).Resize(50).Value _
= cells(i,2).value
j = j + 1
if j 256 then
msgbox "Out of columns"
exit sub
end if
end if
Next

--
Regards,
Tom Ogilvy


"HJ" wrote in message
...
I can't seem to get this to work. When I ran it the first time it was
copying the wrong information. My computer froze so I needed to

restart
and
I can't get it to work again to tell you which information it was

copying.

"Alok" wrote:

Try the following Macro

Sub Test2()
Dim i%
i = 1
With Sheet1
Do While .Cells(18 + 52 * (i - 1), 2).Value < ""
With .Range(.Cells(18 + 52 * (i - 1), 1), .Cells(18 +

52 *
(i)
- 1, 1))
.Value = Sheet1.Cells(18 + 52 * (i - 1), 2).Value
End With
i = i + 1
Loop
End With
End Sub


Alok Joshi

"HJ" wrote:

I would like to create a macro that looks at cell B18, if there is

data in
that cell, then copy that data to range A18:A68, then skip 52 rows

and
look
at cell B70, if there is data in that cell, then copy that data to

range
B70:B120, then skip 52 rows and repeat until there is no data in

the
cell.

Can someone assist with that code? I have recorded a macro to

accomplish
this in the past but now the spreadsheet I have doesn't have a set

number of
rows anymore. I don't think that recording it will assure that I

will
always
pick up all data if rows are added.

Thanks again for your help.

HJ






  #8   Report Post  
Posted to microsoft.public.excel.programming
HJ HJ is offline
external usenet poster
 
Posts: 28
Default Code assistance needed

Thanks, it works like a charm.

Can you take a look at the post - Macro Revision needed from yesterday? You
and Ron de Bruin had helped me with the original macro that I am trying to
modify.

"Tom Ogilvy" wrote:

My bad

for i = 18 to 65536 step 52
if cells(i,2).Value = "" then exit sub
cells(i,1).Resize(50).Value _
= cells(i,2).value
Next

--
Regards,
Tom Ogilvy



"HJ" wrote in message
...
Thanks Tom. I tried your code and am getting an end if without block if

error.

"Tom Ogilvy" wrote:

for i = 18 to 65536 step 52
if cells(i,2).Value = "" then exit sub
cells(i,1).Resize(50).Value _
= cells(i,2).value
end if
Next


Your example had the destination moving from left to right by column. I
assumed that was a mistake and you wanted them in column A. If not

j = 1
for i = 18 to 65536 step 52
if cells(i,2).Value = "" then exit sub
cells(i,j).Resize(50).Value _
= cells(i,2).value
j = j + 1
if j 256 then
msgbox "Out of columns"
exit sub
end if
end if
Next

--
Regards,
Tom Ogilvy


"HJ" wrote in message
...
I can't seem to get this to work. When I ran it the first time it was
copying the wrong information. My computer froze so I needed to

restart
and
I can't get it to work again to tell you which information it was

copying.

"Alok" wrote:

Try the following Macro

Sub Test2()
Dim i%
i = 1
With Sheet1
Do While .Cells(18 + 52 * (i - 1), 2).Value < ""
With .Range(.Cells(18 + 52 * (i - 1), 1), .Cells(18 +

52 *
(i)
- 1, 1))
.Value = Sheet1.Cells(18 + 52 * (i - 1), 2).Value
End With
i = i + 1
Loop
End With
End Sub


Alok Joshi

"HJ" wrote:

I would like to create a macro that looks at cell B18, if there is
data in
that cell, then copy that data to range A18:A68, then skip 52 rows

and
look
at cell B70, if there is data in that cell, then copy that data to
range
B70:B120, then skip 52 rows and repeat until there is no data in

the
cell.

Can someone assist with that code? I have recorded a macro to
accomplish
this in the past but now the spreadsheet I have doesn't have a set
number of
rows anymore. I don't think that recording it will assure that I

will
always
pick up all data if rows are added.

Thanks again for your help.

HJ






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
Lookup assistance needed HowardM Excel Worksheet Functions 9 December 9th 09 05:13 PM
formula assistance needed Eric_in_EVV[_2_] Excel Worksheet Functions 2 October 27th 09 08:31 PM
CODE Assistance needed PLEASE please please N.F[_2_] Excel Discussion (Misc queries) 0 July 9th 07 08:36 PM
VBA Assistance Needed RalphB Excel Discussion (Misc queries) 5 February 22nd 06 06:16 PM
Macro assistance needed HJ Excel Programming 3 November 2nd 04 10:46 PM


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