Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 468
Default Copy noncontigous cells to next sheet

I'm trying to copy the values from A1 and C1 (only)
to my next sheet (sheet2) into cell A1:B1


Sub foo()
Dim Qcell As String
Dim Jcell As String
Qcell = ActiveCell.Address(0, 0)
Jcell = ActiveCell.Offset(0, 2).Address(0, 0)
????????

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Copy noncontigous cells to next sheet

Sub foo()
Sheets("Sheet1").Range("A1").Copy Sheets("Sheet2").Range("A1")
Sheets("Sheet1").Range("C1").Copy Sheets("Sheet2").Range("B1")
End Sub

--
Gary''s Student - gsnu200723
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 468
Default Copy noncontigous cells to next sheet

That's it? -- at one point I thought of doing them separately (like this)
but thought there is probably a "fancier way" of combining A1 and C1.

Not so, huh?

Thanks,

Jim

"Gary''s Student" wrote:

Sub foo()
Sheets("Sheet1").Range("A1").Copy Sheets("Sheet2").Range("A1")
Sheets("Sheet1").Range("C1").Copy Sheets("Sheet2").Range("B1")
End Sub

--
Gary''s Student - gsnu200723

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Copy noncontigous cells to next sheet

Sometimes simple is "good enough".

If you are interested in a more general solution:

arbitrary collection of cells in Sheet1 to contiguous cells in a single row
in Sheet2, check back later.
--
Gary''s Student - gsnu200723


"JMay" wrote:

That's it? -- at one point I thought of doing them separately (like this)
but thought there is probably a "fancier way" of combining A1 and C1.

Not so, huh?

Thanks,

Jim

"Gary''s Student" wrote:

Sub foo()
Sheets("Sheet1").Range("A1").Copy Sheets("Sheet2").Range("A1")
Sheets("Sheet1").Range("C1").Copy Sheets("Sheet2").Range("B1")
End Sub

--
Gary''s Student - gsnu200723

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 468
Default Copy noncontigous cells to next sheet

I understand and also appreciate your assistance. All this was my trying to
help the OP below (earlier) with the Subject line:

Want to move several cells info to next available ...

There you will see my proposed dulution (which incorporated your suggestion)..

Jim

"Gary''s Student" wrote:

Sometimes simple is "good enough".

If you are interested in a more general solution:

arbitrary collection of cells in Sheet1 to contiguous cells in a single row
in Sheet2, check back later.
--
Gary''s Student - gsnu200723


"JMay" wrote:

That's it? -- at one point I thought of doing them separately (like this)
but thought there is probably a "fancier way" of combining A1 and C1.

Not so, huh?

Thanks,

Jim

"Gary''s Student" wrote:

Sub foo()
Sheets("Sheet1").Range("A1").Copy Sheets("Sheet2").Range("A1")
Sheets("Sheet1").Range("C1").Copy Sheets("Sheet2").Range("B1")
End Sub

--
Gary''s Student - gsnu200723



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 17
Default Copy noncontigous cells to next sheet


With a single line use,

Range("sheet1!A1,sheet1!c1").Copy Range("sheet2!A1")

or use Union function as per below modified code of your example.


Sub foo()
Dim Qcell As Range
Dim Jcell As Range

Set Qcell = ActiveCell
Set Jcell = ActiveCell.Offset(0, 2)

Union(Qcell, Jcell).Copy Range("Sheet2!a1")

End Sub



Regards,

Shailesh Shah
http://in.geocities.com/shahshaileshs/
(Excel Add-ins Page)



"JMay" wrote:

I'm trying to copy the values from A1 and C1 (only)
to my next sheet (sheet2) into cell A1:B1


Sub foo()
Dim Qcell As String
Dim Jcell As String
Qcell = ActiveCell.Address(0, 0)
Jcell = ActiveCell.Offset(0, 2).Address(0, 0)
????????

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 468
Default Copy noncontigous cells to next sheet

Union(Qcell, Jcell).Copy Range("Sheet2!a1") -- THAT's IT !!!

That's what I was looking for, -- how exciting...
Tks Shailesh,

Jim

"Shailesh Shah" wrote:


With a single line use,

Range("sheet1!A1,sheet1!c1").Copy Range("sheet2!A1")

or use Union function as per below modified code of your example.


Sub foo()
Dim Qcell As Range
Dim Jcell As Range

Set Qcell = ActiveCell
Set Jcell = ActiveCell.Offset(0, 2)

Union(Qcell, Jcell).Copy Range("Sheet2!a1")

End Sub



Regards,

Shailesh Shah
http://in.geocities.com/shahshaileshs/
(Excel Add-ins Page)



"JMay" wrote:

I'm trying to copy the values from A1 and C1 (only)
to my next sheet (sheet2) into cell A1:B1


Sub foo()
Dim Qcell As String
Dim Jcell As String
Qcell = ActiveCell.Address(0, 0)
Jcell = ActiveCell.Offset(0, 2).Address(0, 0)
????????

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
Copy cells from one sheet to the next available row on another? clarkie Excel Discussion (Misc queries) 2 February 26th 07 07:12 PM
Copy sheet 1 data to sheet 2 cells. Tom Doggett Excel Worksheet Functions 1 July 19th 05 11:49 PM
Array Formula, noncontigous range Werner Rohrmoser Excel Worksheet Functions 1 June 22nd 05 12:11 PM
Copy row sheet-sheet skipping unqualified cells StevenL Excel Worksheet Functions 0 April 16th 05 11:11 PM
Noncontigous Cells Alan Beban Excel Worksheet Functions 1 March 10th 05 10:16 PM


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