PC Review


Reply
Thread Tools Rate Thread

Copy and past as values

 
 
=?Utf-8?B?UGl5dXNo?=
Guest
Posts: n/a
 
      9th Aug 2007
Hi
I am new to vba and macros. need urgent help
In Sheet 1, I am trying to copy a cell C1 and paste as values in cell D1 and
then from C2 to D2. The function needs to progress in this fashion one by
one. I want to create a macro and still be able to run it from a different
worksheet say Sheet 2.

Kindly help

Regards
Piyush
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlrZSBI?=
Guest
Posts: n/a
 
      9th Aug 2007
Try

Sub copy()
Dim myRange As Range
Set myRange = Sheets("sheet1").Range("C1:C20") ' Change to suit
For Each c In myRange
c.Offset(0, 1).Value = c.Value
Next
End Sub


Alt +F11, Insert module and paste code in.

Mike

"Piyush" wrote:

> Hi
> I am new to vba and macros. need urgent help
> In Sheet 1, I am trying to copy a cell C1 and paste as values in cell D1 and
> then from C2 to D2. The function needs to progress in this fashion one by
> one. I want to create a macro and still be able to run it from a different
> worksheet say Sheet 2.
>
> Kindly help
>
> Regards
> Piyush

 
Reply With Quote
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      9th Aug 2007
You can copy the code below and paste it into the standard code
module by pressing Alt + F11. If the code module is dark, then
on the menu Insert>Module and then paste the code in.
You can assign a keyboard shortcut to run the code or run it by
clicking Tools>Macro>Macros and then selecting this macro before
clicking Run:

Sub cpy()
lr = Worksheets(1).Cells(Rows.Count, 3).End(xlUp).Row
' Gets the last used row number. If your data is in
' a different sheet change the number (1) to the
' appropriate index number.
For Each c In Worksheets(1).Range("$C$2:$C" & lr)
c.Copy
c.Offset(0, 1).PasteSpecial Paste:=xlValues
Next
Application.CutCopyMode = False
End Sub


"Mike H" wrote:

> Try
>
> Sub copy()
> Dim myRange As Range
> Set myRange = Sheets("sheet1").Range("C1:C20") ' Change to suit
> For Each c In myRange
> c.Offset(0, 1).Value = c.Value
> Next
> End Sub
>
>
> Alt +F11, Insert module and paste code in.
>
> Mike
>
> "Piyush" wrote:
>
> > Hi
> > I am new to vba and macros. need urgent help
> > In Sheet 1, I am trying to copy a cell C1 and paste as values in cell D1 and
> > then from C2 to D2. The function needs to progress in this fashion one by
> > one. I want to create a macro and still be able to run it from a different
> > worksheet say Sheet 2.
> >
> > Kindly help
> >
> > Regards
> > Piyush

 
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
Copy and Past Values AND Formatting AND Text KKD Microsoft Excel Misc 1 6th May 2010 06:25 PM
copy and past numeric values only Trip Bee Microsoft Excel Programming 3 15th Nov 2009 09:38 AM
Copy Past Values Ed Davis Microsoft Excel Misc 14 6th Oct 2009 03:24 AM
Find matching values, copy/paste values as well as values in ColA ryguy7272 Microsoft Excel Programming 2 28th Sep 2009 06:20 AM
Macro to add row and past values on new worksheet. HLP Bruno Microsoft Excel Programming 6 17th Oct 2008 01:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:09 AM.