Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 InsertModule and then paste the code in. You can assign a keyboard shortcut to run the code or run it by clicking ToolsMacroMacros 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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy and Past Values AND Formatting AND Text | Excel Discussion (Misc queries) | |||
Copy Past Values | Excel Discussion (Misc queries) | |||
Copy and Past | Excel Discussion (Misc queries) | |||
Referential Copy and Past | Excel Programming | |||
Copy and past to different sheets | Excel Discussion (Misc queries) |