PC Review


Reply
Thread Tools Rate Thread

copy/paste without highlighted cells

 
 
Fan924
Guest
Posts: n/a
 
      27th Feb 2009
The macro below leaves two sheets with a highlighted column on
each.How do I do this copy/paste without selecting data leaving both
sheets without any highlighted cells?

Sub WriteMap()
Dim MySheet As Variant
Dim MyTarget As Variant
MySheet = ActiveSheet.Name
MyTarget = Range("A1").Value
Range("S2:S293").Select
Selection.Copy
Sheets("Sheet1").Select
Range("C" & MyTarget).Select
Selection.PasteSpecial Paste:=xlValues
Sheets(MySheet).Select
End Sub
 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      27th Feb 2009
Hi,

Try this

Sub WriteMap()
Dim MySheet As String
Dim MyTarget As Long
MySheet = ActiveSheet.Name
MyTarget = Range("A1").Value
Range("S2:S293").Copy
Sheets("Sheet1").Range("C" & MyTarget).PasteSpecial Paste:=xlValues
Application.Goto Worksheets("Sheet1").Range("A1"), True
Sheets(MySheet).Select
End Sub

"Fan924" wrote:

> The macro below leaves two sheets with a highlighted column on
> each.How do I do this copy/paste without selecting data leaving both
> sheets without any highlighted cells?
>
> Sub WriteMap()
> Dim MySheet As Variant
> Dim MyTarget As Variant
> MySheet = ActiveSheet.Name
> MyTarget = Range("A1").Value
> Range("S2:S293").Select
> Selection.Copy
> Sheets("Sheet1").Select
> Range("C" & MyTarget).Select
> Selection.PasteSpecial Paste:=xlValues
> Sheets(MySheet).Select
> End Sub
>

 
Reply With Quote
 
 
 
 
Revolvr
Guest
Posts: n/a
 
      27th Feb 2009
On Feb 27, 12:19*pm, Fan924 <(E-Mail Removed)> wrote:
> The macro below leaves two sheets with a highlighted column on
> each.How do I do this copy/paste without selecting data leaving both
> sheets without any highlighted cells?
>
> Sub WriteMap()
> Dim MySheet As Variant
> Dim MyTarget As Variant
> * * MySheet = ActiveSheet.Name
> * * MyTarget = Range("A1").Value
> * * Range("S2:S293").Select
> * * Selection.Copy
> * * Sheets("Sheet1").Select
> * * Range("C" & MyTarget).Select
> * * Selection.PasteSpecial Paste:=xlValues
> * * Sheets(MySheet).Select
> End Sub


After you do the copy, add something like Range("A1").Select
You still have something selected but its only 1 cell, hardly
noticeable.
I don't know a way to unselect everything.
 
Reply With Quote
 
Fan924
Guest
Posts: n/a
 
      28th Feb 2009
On Feb 27, 1:36 pm, mdmackillop <(E-Mail Removed)>
wrote:
> As you are doing a PasteSpecial Values, instead try
> Sub WriteMap()
> Dim Rng As Range
> Set Rng = Range("S2:S293")
> Sheets("Sheet1").Range("C" &
> Range("A1")).Resize(Rng.Cells.Count).Value = Rng.Value
> End Sub
>
> --
> mdmackillop
> ------------------------------------------------------------------------
> mdmackillop's Profile:http://www.thecodecage.com/forumz/member.php?userid=113
> View this thread:http://www.thecodecage.com/forumz/sh...ad.php?t=69236


Exactly what I was looking for mdmackillop, thanks.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
counting highlighted cells or font color cells Tired Dan Microsoft Excel Discussion 0 10th Dec 2007 11:41 PM
Why would format cells not want to open when cells are highlighted =?Utf-8?B?dGVyaWRheXRvbg==?= Microsoft Excel Crashes 1 1st May 2006 01:11 PM
Why aren't my cells highlighted when I select multiple cells? =?Utf-8?B?VENocmlzdGlhbg==?= Microsoft Excel Setup 0 26th Jan 2005 11:23 PM
cells highlighted and unable to remove highlighted debbie Microsoft Excel Worksheet Functions 1 3rd Oct 2004 05:48 AM
Highlighted words won't stay highlighted killme Windows XP Help 0 12th Dec 2003 01:31 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:26 AM.