Copy-Paste - Same Sheet and Process, but for the entire spreadsheet2019 Community Moderator ElectionHow to avoid using Select in Excel VBAVBA Copy and paste a range of numbersHow do you copy and paste into Git BashHow do you select the entire excel sheet with Range using Macro in VBA?Copy and paste to another sheet first empty row, pastes over the previous row if first cell is emptyCopy Range From One Sheet Paste Part of Range In Same Sheet Based On Cell Value On Another SheetCopy Range Sheet1 Paste in Active Cell Sheet 2Excel VBA: How to copy multiple ranges from same sheetMacro to Copy and Paste into Email bodyHow do I use a date reference on 1 sheet to use as a place to paste data on multiple other sheets but copied on same sheet as to be pastedCopy/Paste Yellow Highlighted Cells in a new WorkSheet VBA
Fastest way to pop N items from a large dict
Violin - Can double stops be played when the strings are not next to each other?
Math equation in non italic font
Why did it take so long to abandon sail after steamships were demonstrated?
Examples of transfinite towers
Is it insecure to send a password in a `curl` command?
Most cost effective thermostat setting: consistent temperature vs. lowest temperature possible
Official degrees of earth’s rotation per day
What is the Japanese sound word for the clinking of money?
Welcoming 2019 Pi day: How to draw the letter π?
What do you call the act of removing a part of a word and replacing it with an apostrophe
What is a ^ b and (a & b) << 1?
Are all passive ability checks floors for active ability checks?
Do I need to be arrogant to get ahead?
Shortcut for setting origin to vertex
If I can solve Sudoku, can I solve the Travelling Salesman Problem (TSP)? If so, how?
Bach's Toccata and Fugue in D minor breaks the "no parallel octaves" rule?
Equivalents to the present tense
Why does overlay work only on the first tcolorbox?
Python if-else code style for reduced code for rounding floats
Knife as defense against stray dogs
Bacteria contamination inside a thermos bottle
Is it normal that my co-workers at a fitness company criticize my food choices?
How could a scammer know the apps on my phone / iTunes account?
Copy-Paste - Same Sheet and Process, but for the entire spreadsheet
2019 Community Moderator ElectionHow to avoid using Select in Excel VBAVBA Copy and paste a range of numbersHow do you copy and paste into Git BashHow do you select the entire excel sheet with Range using Macro in VBA?Copy and paste to another sheet first empty row, pastes over the previous row if first cell is emptyCopy Range From One Sheet Paste Part of Range In Same Sheet Based On Cell Value On Another SheetCopy Range Sheet1 Paste in Active Cell Sheet 2Excel VBA: How to copy multiple ranges from same sheetMacro to Copy and Paste into Email bodyHow do I use a date reference on 1 sheet to use as a place to paste data on multiple other sheets but copied on same sheet as to be pastedCopy/Paste Yellow Highlighted Cells in a new WorkSheet VBA
I'm new to VBA coding (I mostly work with R) and I am having trouble writing a macro to copy and paste. Specifically, I can do the first command fine, but when I go to the next row to do the same thing, it reverts back to the initial cell.
Here's the code that I'm working with:
Keyboard Shortcut: Ctrl+h
Range("B2").Copy Range("C1")
Range("B4").Copy Range("C3")
Range("B6").Copy Range("C5")
And so on...
This does exactly what I want it to do, but I was wondering if there is a way to generalize it so that I can highlight the first cell of each "block" that I wish to do this to (i.e., A1,A2,B1,B2,C1,C2 etc.) and just use the keyboard shortcut. I got it to work partially using:
Sub Format()
' Format Macro
' Keyboard Shortcut: Ctrl+h
Selection.Cut
ActiveCell.Offset(-1, 1).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(1, -1).Range("A1").Select
Selection.EntireRow.Delete
End Sub
But that always reverts back to the initial cell (A1 in this case) once I move on to the next block.
Thanks for your help!
excel vba copy-paste
add a comment |
I'm new to VBA coding (I mostly work with R) and I am having trouble writing a macro to copy and paste. Specifically, I can do the first command fine, but when I go to the next row to do the same thing, it reverts back to the initial cell.
Here's the code that I'm working with:
Keyboard Shortcut: Ctrl+h
Range("B2").Copy Range("C1")
Range("B4").Copy Range("C3")
Range("B6").Copy Range("C5")
And so on...
This does exactly what I want it to do, but I was wondering if there is a way to generalize it so that I can highlight the first cell of each "block" that I wish to do this to (i.e., A1,A2,B1,B2,C1,C2 etc.) and just use the keyboard shortcut. I got it to work partially using:
Sub Format()
' Format Macro
' Keyboard Shortcut: Ctrl+h
Selection.Cut
ActiveCell.Offset(-1, 1).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(1, -1).Range("A1").Select
Selection.EntireRow.Delete
End Sub
But that always reverts back to the initial cell (A1 in this case) once I move on to the next block.
Thanks for your help!
excel vba copy-paste
What do you want to do, copy or cut the active cell up 1 and 1 to the right? You should have a look at stackoverflow.com/questions/10714251/…
– SJR
Mar 6 at 20:47
I suppose it doesn't matter whether I copy or cut the cell and move it up 1 right 1 because I am ultimately removing the row that the cell was cut or copied from entirely. I assume that there's not that much of a difference between cutting and copying in terms of code (aside from the obvious cut vs. copy). I have a for loop written that gets rid of the rows after everything is copied, I just cant figure out how to do the initial copying or cutting.
– Cody_15243
Mar 6 at 20:51
add a comment |
I'm new to VBA coding (I mostly work with R) and I am having trouble writing a macro to copy and paste. Specifically, I can do the first command fine, but when I go to the next row to do the same thing, it reverts back to the initial cell.
Here's the code that I'm working with:
Keyboard Shortcut: Ctrl+h
Range("B2").Copy Range("C1")
Range("B4").Copy Range("C3")
Range("B6").Copy Range("C5")
And so on...
This does exactly what I want it to do, but I was wondering if there is a way to generalize it so that I can highlight the first cell of each "block" that I wish to do this to (i.e., A1,A2,B1,B2,C1,C2 etc.) and just use the keyboard shortcut. I got it to work partially using:
Sub Format()
' Format Macro
' Keyboard Shortcut: Ctrl+h
Selection.Cut
ActiveCell.Offset(-1, 1).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(1, -1).Range("A1").Select
Selection.EntireRow.Delete
End Sub
But that always reverts back to the initial cell (A1 in this case) once I move on to the next block.
Thanks for your help!
excel vba copy-paste
I'm new to VBA coding (I mostly work with R) and I am having trouble writing a macro to copy and paste. Specifically, I can do the first command fine, but when I go to the next row to do the same thing, it reverts back to the initial cell.
Here's the code that I'm working with:
Keyboard Shortcut: Ctrl+h
Range("B2").Copy Range("C1")
Range("B4").Copy Range("C3")
Range("B6").Copy Range("C5")
And so on...
This does exactly what I want it to do, but I was wondering if there is a way to generalize it so that I can highlight the first cell of each "block" that I wish to do this to (i.e., A1,A2,B1,B2,C1,C2 etc.) and just use the keyboard shortcut. I got it to work partially using:
Sub Format()
' Format Macro
' Keyboard Shortcut: Ctrl+h
Selection.Cut
ActiveCell.Offset(-1, 1).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(1, -1).Range("A1").Select
Selection.EntireRow.Delete
End Sub
But that always reverts back to the initial cell (A1 in this case) once I move on to the next block.
Thanks for your help!
excel vba copy-paste
excel vba copy-paste
edited Mar 7 at 8:00
Pᴇʜ
23.9k62952
23.9k62952
asked Mar 6 at 20:39
Cody_15243Cody_15243
1
1
What do you want to do, copy or cut the active cell up 1 and 1 to the right? You should have a look at stackoverflow.com/questions/10714251/…
– SJR
Mar 6 at 20:47
I suppose it doesn't matter whether I copy or cut the cell and move it up 1 right 1 because I am ultimately removing the row that the cell was cut or copied from entirely. I assume that there's not that much of a difference between cutting and copying in terms of code (aside from the obvious cut vs. copy). I have a for loop written that gets rid of the rows after everything is copied, I just cant figure out how to do the initial copying or cutting.
– Cody_15243
Mar 6 at 20:51
add a comment |
What do you want to do, copy or cut the active cell up 1 and 1 to the right? You should have a look at stackoverflow.com/questions/10714251/…
– SJR
Mar 6 at 20:47
I suppose it doesn't matter whether I copy or cut the cell and move it up 1 right 1 because I am ultimately removing the row that the cell was cut or copied from entirely. I assume that there's not that much of a difference between cutting and copying in terms of code (aside from the obvious cut vs. copy). I have a for loop written that gets rid of the rows after everything is copied, I just cant figure out how to do the initial copying or cutting.
– Cody_15243
Mar 6 at 20:51
What do you want to do, copy or cut the active cell up 1 and 1 to the right? You should have a look at stackoverflow.com/questions/10714251/…
– SJR
Mar 6 at 20:47
What do you want to do, copy or cut the active cell up 1 and 1 to the right? You should have a look at stackoverflow.com/questions/10714251/…
– SJR
Mar 6 at 20:47
I suppose it doesn't matter whether I copy or cut the cell and move it up 1 right 1 because I am ultimately removing the row that the cell was cut or copied from entirely. I assume that there's not that much of a difference between cutting and copying in terms of code (aside from the obvious cut vs. copy). I have a for loop written that gets rid of the rows after everything is copied, I just cant figure out how to do the initial copying or cutting.
– Cody_15243
Mar 6 at 20:51
I suppose it doesn't matter whether I copy or cut the cell and move it up 1 right 1 because I am ultimately removing the row that the cell was cut or copied from entirely. I assume that there's not that much of a difference between cutting and copying in terms of code (aside from the obvious cut vs. copy). I have a for loop written that gets rid of the rows after everything is copied, I just cant figure out how to do the initial copying or cutting.
– Cody_15243
Mar 6 at 20:51
add a comment |
1 Answer
1
active
oldest
votes
Something like this? This is a one-off operation, but could be broadened if there some broader pattern exists.
Sub x()
With ActiveCell
.Offset(-1, 1).Value = .Value
.EntireRow.Delete
End With
End Sub
That did the trick. Thank you!
– Cody_15243
Mar 6 at 21:24
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031791%2fcopy-paste-same-sheet-and-process-but-for-the-entire-spreadsheet%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Something like this? This is a one-off operation, but could be broadened if there some broader pattern exists.
Sub x()
With ActiveCell
.Offset(-1, 1).Value = .Value
.EntireRow.Delete
End With
End Sub
That did the trick. Thank you!
– Cody_15243
Mar 6 at 21:24
add a comment |
Something like this? This is a one-off operation, but could be broadened if there some broader pattern exists.
Sub x()
With ActiveCell
.Offset(-1, 1).Value = .Value
.EntireRow.Delete
End With
End Sub
That did the trick. Thank you!
– Cody_15243
Mar 6 at 21:24
add a comment |
Something like this? This is a one-off operation, but could be broadened if there some broader pattern exists.
Sub x()
With ActiveCell
.Offset(-1, 1).Value = .Value
.EntireRow.Delete
End With
End Sub
Something like this? This is a one-off operation, but could be broadened if there some broader pattern exists.
Sub x()
With ActiveCell
.Offset(-1, 1).Value = .Value
.EntireRow.Delete
End With
End Sub
answered Mar 6 at 21:05
SJRSJR
13.2k31219
13.2k31219
That did the trick. Thank you!
– Cody_15243
Mar 6 at 21:24
add a comment |
That did the trick. Thank you!
– Cody_15243
Mar 6 at 21:24
That did the trick. Thank you!
– Cody_15243
Mar 6 at 21:24
That did the trick. Thank you!
– Cody_15243
Mar 6 at 21:24
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031791%2fcopy-paste-same-sheet-and-process-but-for-the-entire-spreadsheet%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What do you want to do, copy or cut the active cell up 1 and 1 to the right? You should have a look at stackoverflow.com/questions/10714251/…
– SJR
Mar 6 at 20:47
I suppose it doesn't matter whether I copy or cut the cell and move it up 1 right 1 because I am ultimately removing the row that the cell was cut or copied from entirely. I assume that there's not that much of a difference between cutting and copying in terms of code (aside from the obvious cut vs. copy). I have a for loop written that gets rid of the rows after everything is copied, I just cant figure out how to do the initial copying or cutting.
– Cody_15243
Mar 6 at 20:51