Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 148
Default Need a macro

Ihave data in col A & B
Theamount of data can be only 10 lines or could be 100 lines
lets assume I have 99 entries in col A & B
I would like the macro to copy lines 33 to 66 to start at d1 & d1
then copy the remiander (ie line 67 to 69) to start at f1 & g1
Thanks for the help
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 903
Default Need a macro

The description of your problem leaves a lot to be desired,
but it is understandable if you know the answer, you want to
snake the columns, see
http://www.mvps.org/dmcritchie/excel....htm#snakecols
---
HTH,
David McRitchie, Microsoft MVP - Excel
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"pcor" wrote in message ...
Ihave data in col A & B
Theamount of data can be only 10 lines or could be 100 lines
lets assume I have 99 entries in col A & B
I would like the macro to copy lines 33 to 66 to start at d1 & d1
then copy the remiander (ie line 67 to 69) to start at f1 & g1



  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 148
Default Need a macro

Sorry about that..I will try and explain better
Lets assume I have 100 lines of data starting at line 1 in col A & B
I would like to have a macro that would leave the first third of the data(ie
lines 1 to 33) in its original place.
The next move would grab the second third(ie lines 34 to 66) and copy that
date to col d & E startubg at line 1
The remainder of the date located at A & B 67 to 100 would be COPIED to line
1 of column g & H
Hope that is more clear
Thanks
Ian M

"David McRitchie" wrote:

The description of your problem leaves a lot to be desired,
but it is understandable if you know the answer, you want to
snake the columns, see
http://www.mvps.org/dmcritchie/excel....htm#snakecols
---
HTH,
David McRitchie, Microsoft MVP - Excel
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"pcor" wrote in message ...
Ihave data in col A & B
Theamount of data can be only 10 lines or could be 100 lines
lets assume I have 99 entries in col A & B
I would like the macro to copy lines 33 to 66 to start at d1 & d1
then copy the remiander (ie line 67 to 69) to start at f1 & g1




  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 22,906
Default Need a macro

pcor

Something like this?

Sub Set_Three_Times()
Dim iSource As Long
Dim iTarget As Long
Dim cCols As Long
Dim rrows As Long

iSource = 1
iTarget = 1
cCols = InputBox("Original Number of Columns")
rrows = InputBox("rows per set")
Do
Cells(iSource, "A").Resize(rrows, cCols) _
.Cut Destination:=Cells(iTarget, "A")
Cells(iSource + rrows, "A").Resize(rrows, cCols) _
.Cut Destination:=Cells(iTarget, (cCols + 1))
Cells(iSource + (2 * rrows), "A").Resize(rrows, cCols) _
.Cut Destination:=Cells(iTarget, (2 * cCols) + 1)
iSource = iSource + (rrows * (cCols + 1))
iTarget = iTarget + (rrows + 1)
Loop Until IsEmpty(Cells(iSource, "A").Value)

End Sub


Gord Dibben MS Excel MVP

On Tue, 5 Sep 2006 18:01:01 -0700, pcor wrote:

Sorry about that..I will try and explain better
Lets assume I have 100 lines of data starting at line 1 in col A & B
I would like to have a macro that would leave the first third of the data(ie
lines 1 to 33) in its original place.
The next move would grab the second third(ie lines 34 to 66) and copy that
date to col d & E startubg at line 1
The remainder of the date located at A & B 67 to 100 would be COPIED to line
1 of column g & H
Hope that is more clear
Thanks
Ian M

"David McRitchie" wrote:

The description of your problem leaves a lot to be desired,
but it is understandable if you know the answer, you want to
snake the columns, see
http://www.mvps.org/dmcritchie/excel....htm#snakecols
---
HTH,
David McRitchie, Microsoft MVP - Excel
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"pcor" wrote in message ...
Ihave data in col A & B
Theamount of data can be only 10 lines or could be 100 lines
lets assume I have 99 entries in col A & B
I would like the macro to copy lines 33 to 66 to start at d1 & d1
then copy the remiander (ie line 67 to 69) to start at f1 & g1





  #5   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 148
Default Need a macro

Thanks...That is EXACTLY what I need with three small exceptions.
I want to copy COL A and Col B(not just Col A) and I want to place the
first cut in col D & E(leaving a col C blank). and the same for the next cut.
That would go into col g & H leaving Col F blank.
And just one more thing...
I would very much line to COPY the data and not cut it. (IE Leave the
original data where it was
Many thanks In advance
Ianm

"Gord Dibben" wrote:

pcor

Something like this?

Sub Set_Three_Times()
Dim iSource As Long
Dim iTarget As Long
Dim cCols As Long
Dim rrows As Long

iSource = 1
iTarget = 1
cCols = InputBox("Original Number of Columns")
rrows = InputBox("rows per set")
Do
Cells(iSource, "A").Resize(rrows, cCols) _
.Cut Destination:=Cells(iTarget, "A")
Cells(iSource + rrows, "A").Resize(rrows, cCols) _
.Cut Destination:=Cells(iTarget, (cCols + 1))
Cells(iSource + (2 * rrows), "A").Resize(rrows, cCols) _
.Cut Destination:=Cells(iTarget, (2 * cCols) + 1)
iSource = iSource + (rrows * (cCols + 1))
iTarget = iTarget + (rrows + 1)
Loop Until IsEmpty(Cells(iSource, "A").Value)

End Sub


Gord Dibben MS Excel MVP

On Tue, 5 Sep 2006 18:01:01 -0700, pcor wrote:

Sorry about that..I will try and explain better
Lets assume I have 100 lines of data starting at line 1 in col A & B
I would like to have a macro that would leave the first third of the data(ie
lines 1 to 33) in its original place.
The next move would grab the second third(ie lines 34 to 66) and copy that
date to col d & E startubg at line 1
The remainder of the date located at A & B 67 to 100 would be COPIED to line
1 of column g & H
Hope that is more clear
Thanks
Ian M

"David McRitchie" wrote:

The description of your problem leaves a lot to be desired,
but it is understandable if you know the answer, you want to
snake the columns, see
http://www.mvps.org/dmcritchie/excel....htm#snakecols
---
HTH,
David McRitchie, Microsoft MVP - Excel
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"pcor" wrote in message ...
Ihave data in col A & B
Theamount of data can be only 10 lines or could be 100 lines
lets assume I have 99 entries in col A & B
I would like the macro to copy lines 33 to 66 to start at d1 & d1
then copy the remiander (ie line 67 to 69) to start at f1 & g1







  #6   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 903
Default Need a macro

Change the line of code
cCols = InputBox("Original Number of Columns")

to
cCols = 2
but I would really recommend the following if column 3 is empty
cCols = 3

--
HTH,
David McRitchie, Microsoft MVP - Excel
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"pcor" wrote in message ...
Thanks...That is EXACTLY what I need with three small exceptions.
I want to copy COL A and Col B(not just Col A) and I want to place the
first cut in col D & E(leaving a col C blank). and the same for the next cut.
That would go into col g & H leaving Col F blank.
And just one more thing...
I would very much line to COPY the data and not cut it. (IE Leave the
original data where it was
Many thanks In advance
Ianm

"Gord Dibben" wrote:

pcor

Something like this?

Sub Set_Three_Times()
Dim iSource As Long
Dim iTarget As Long
Dim cCols As Long
Dim rrows As Long

iSource = 1
iTarget = 1
cCols = InputBox("Original Number of Columns")
rrows = InputBox("rows per set")
Do
Cells(iSource, "A").Resize(rrows, cCols) _
.Cut Destination:=Cells(iTarget, "A")
Cells(iSource + rrows, "A").Resize(rrows, cCols) _
.Cut Destination:=Cells(iTarget, (cCols + 1))
Cells(iSource + (2 * rrows), "A").Resize(rrows, cCols) _
.Cut Destination:=Cells(iTarget, (2 * cCols) + 1)
iSource = iSource + (rrows * (cCols + 1))
iTarget = iTarget + (rrows + 1)
Loop Until IsEmpty(Cells(iSource, "A").Value)

End Sub


Gord Dibben MS Excel MVP

On Tue, 5 Sep 2006 18:01:01 -0700, pcor wrote:

Sorry about that..I will try and explain better
Lets assume I have 100 lines of data starting at line 1 in col A & B
I would like to have a macro that would leave the first third of the data(ie
lines 1 to 33) in its original place.
The next move would grab the second third(ie lines 34 to 66) and copy that
date to col d & E startubg at line 1
The remainder of the date located at A & B 67 to 100 would be COPIED to line
1 of column g & H
Hope that is more clear
Thanks
Ian M

"David McRitchie" wrote:

The description of your problem leaves a lot to be desired,
but it is understandable if you know the answer, you want to
snake the columns, see
http://www.mvps.org/dmcritchie/excel....htm#snakecols
---
HTH,
David McRitchie, Microsoft MVP - Excel
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"pcor" wrote in message ...
Ihave data in col A & B
Theamount of data can be only 10 lines or could be 100 lines
lets assume I have 99 entries in col A & B
I would like the macro to copy lines 33 to 66 to start at d1 & d1
then copy the remiander (ie line 67 to 69) to start at f1 & g1







  #7   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 148
Default Need a macro

Many thanks for getting me on the right track


"David McRitchie" wrote:

Change the line of code
cCols = InputBox("Original Number of Columns")

to
cCols = 2
but I would really recommend the following if column 3 is empty
cCols = 3

--
HTH,
David McRitchie, Microsoft MVP - Excel
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"pcor" wrote in message ...
Thanks...That is EXACTLY what I need with three small exceptions.
I want to copy COL A and Col B(not just Col A) and I want to place the
first cut in col D & E(leaving a col C blank). and the same for the next cut.
That would go into col g & H leaving Col F blank.
And just one more thing...
I would very much line to COPY the data and not cut it. (IE Leave the
original data where it was
Many thanks In advance
Ianm

"Gord Dibben" wrote:

pcor

Something like this?

Sub Set_Three_Times()
Dim iSource As Long
Dim iTarget As Long
Dim cCols As Long
Dim rrows As Long

iSource = 1
iTarget = 1
cCols = InputBox("Original Number of Columns")
rrows = InputBox("rows per set")
Do
Cells(iSource, "A").Resize(rrows, cCols) _
.Cut Destination:=Cells(iTarget, "A")
Cells(iSource + rrows, "A").Resize(rrows, cCols) _
.Cut Destination:=Cells(iTarget, (cCols + 1))
Cells(iSource + (2 * rrows), "A").Resize(rrows, cCols) _
.Cut Destination:=Cells(iTarget, (2 * cCols) + 1)
iSource = iSource + (rrows * (cCols + 1))
iTarget = iTarget + (rrows + 1)
Loop Until IsEmpty(Cells(iSource, "A").Value)

End Sub


Gord Dibben MS Excel MVP

On Tue, 5 Sep 2006 18:01:01 -0700, pcor wrote:

Sorry about that..I will try and explain better
Lets assume I have 100 lines of data starting at line 1 in col A & B
I would like to have a macro that would leave the first third of the data(ie
lines 1 to 33) in its original place.
The next move would grab the second third(ie lines 34 to 66) and copy that
date to col d & E startubg at line 1
The remainder of the date located at A & B 67 to 100 would be COPIED to line
1 of column g & H
Hope that is more clear
Thanks
Ian M

"David McRitchie" wrote:

The description of your problem leaves a lot to be desired,
but it is understandable if you know the answer, you want to
snake the columns, see
http://www.mvps.org/dmcritchie/excel....htm#snakecols
---
HTH,
David McRitchie, Microsoft MVP - Excel
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"pcor" wrote in message ...
Ihave data in col A & B
Theamount of data can be only 10 lines or could be 100 lines
lets assume I have 99 entries in col A & B
I would like the macro to copy lines 33 to 66 to start at d1 & d1
then copy the remiander (ie line 67 to 69) to start at f1 & g1








  #8   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 22,906
Default Need a macro

Thanks for jump-in David.

Seems pcor is now happy so operation complete.


Gord

On Wed, 6 Sep 2006 13:00:03 -0400, "David McRitchie"
wrote:

Change the line of code
cCols = InputBox("Original Number of Columns")

to
cCols = 2
but I would really recommend the following if column 3 is empty
cCols = 3


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
error when running cut & paste macro Otto Moehrbach Excel Worksheet Functions 4 August 9th 06 01:49 PM
Compiling macro based on cell values simonsmith Excel Discussion (Misc queries) 1 May 16th 06 08:31 PM
Search, Copy, Paste Macro in Excel [email protected] Excel Worksheet Functions 0 January 3rd 06 06:51 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Highlight Range - wrong macro, please edit. Danny Excel Worksheet Functions 8 October 19th 05 11:11 PM


All times are GMT +1. The time now is 06:42 AM.

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"