Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy and Paste 2 columns from a named range?


Hi all,

I have some code that selects a named range and then copies it to a
location, is it possible to select the named range but just copy the
first 18 rows x 2 columns out of it, so if the named range dimension
was 18x4 just copy the contents of the named from columns A & B and
paste to location. I would also need to copy the code to another module
where in that instance it would copy the contents of the named range
from columns C & D.

Any ideas?, Here's the code im using to select the named range,

Regards,
Simon

Sub datachange()
Sheets("User Data").Visible = True

Application.Goto Reference:=Range("B3").Value
Selection.Copy
Sheets("Data View").Select
Range("B5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("User Data").Activate
ActiveWindow.SelectedSheets.Visible = False
Sheets("Data View").Select
Range("A1").Select
Exit Sub
End Sub


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=546299

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Copy and Paste 2 columns from a named range?

Hi Simon Try something like:

Dim rng As Range
Dim rng1 As Range
Dim rng2 As Range


Set rng = Range("NamedRange")

Set rng1 = rng.Resize(18, 2)
Set rng2 = rng.Offset(, 2).Resize(18, 2)



---
Regards,
Norman



"Simon Lloyd"
wrote in message
...

Hi all,

I have some code that selects a named range and then copies it to a
location, is it possible to select the named range but just copy the
first 18 rows x 2 columns out of it, so if the named range dimension
was 18x4 just copy the contents of the named from columns A & B and
paste to location. I would also need to copy the code to another module
where in that instance it would copy the contents of the named range
from columns C & D.

Any ideas?, Here's the code im using to select the named range,

Regards,
Simon

Sub datachange()
Sheets("User Data").Visible = True

Application.Goto Reference:=Range("B3").Value
Selection.Copy
Sheets("Data View").Select
Range("B5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("User Data").Activate
ActiveWindow.SelectedSheets.Visible = False
Sheets("Data View").Select
Range("A1").Select
Exit Sub
End Sub


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile:
http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=546299



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy and Paste 2 columns from a named range?


Thanks Norman..............Worked a treat!

Regards,
Simon


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=546299

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
Paste to next empty cell in named range of cells Sully Excel Discussion (Misc queries) 3 March 4th 10 05:23 PM
Copy data and paste to different sheet named on Group Prem Excel Discussion (Misc queries) 1 February 21st 08 02:56 PM
Finding a named range based on cell value and copy/paste to same sheet? Simon Lloyd[_715_] Excel Programming 1 May 11th 06 11:25 PM
Paste a named range to another range in Excel David Jean Excel Discussion (Misc queries) 2 April 13th 05 02:02 PM
How to paste only certain columns from a listbox into a named range GH[_2_] Excel Programming 2 January 5th 05 12:40 PM


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