Copy Cell To Another Sheet, one after another - vba

I have been trying to find the solution to this for a while now and I do not believe I am searching for the right thing.
Basically what I want to do is copy a cell contents and paste it to another sheet and then delete the contents of the cell that was copied from.
I have one button that corresponds to each cell and I want to write a bit of code which enables you to do this at the click of a button.
Another issue is I don't know the code that would not constantly paste in the same cell over and over, but rather go to the next row and paste there.
What I have at the moment is the following:
Sub Macro1()
Range("I2").Select
Selection.Copy
Sheets("Completed Tasks").Select
Range("A72").Select
ActiveSheet.Paste
Sheets("Projects Live!").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = ""
Range("H2").Select
End Sub
This only refers to the top cell and i have recorded a macro to show essentially what i want.
Hope you can help or point me in the right direction.

Consider:
Sub luxation()
Range("I2").Copy Sheets("Completed Tasks").Range("A72")
Range("I2").Clear
End Sub
This is for a single cell...............you would embed this kind of syntax in a loop.

Related

Command button to paste table based on cell value

I have an Excel sheet in which I'm trying to make a walkthrough type of thing, for training new employees. At its core, I want to have a dropdown menu (got that already) filled with options, and then a command button that will check the contents of the drop down cell, and copy-paste a table from a hidden sheet onto the main sheet. For some reason, I can't get the button to work. This is what I've got so far:
Private Sub button_desk_Click()
Application.ScreenUpdating = False
'Create Table
If Worksheets("Walkthrough").Range("A2").Value2 = "Getting your desk set up" Then
Sheets("Settings").Select
Range("lookup_desksetup[[#All],[Getting your desk setup]]").Select
Selection.Copy
Sheets("Walkthrough").Select
Range("B5").Select
ActiveSheet.Paste
End If
Application.ScreenUpdating = True
End Sub
I've tried a few different approaches for this, including not using the .Select command, but I can't seem to get anything to work.
Sheets("Settings").Select
Range("lookup_desksetup[[#All],[Getting your desk setup]]").Select
Selection.Copy
Sheets("Walkthrough").Select
Range("B5").Select
ActiveSheet.Paste
is a long winded way of saying
Sheets("Settings").Range("lookup_desksetup[[#All],[Getting your desk setup]]").copy _
destination:= Sheets("Walkthrough").Range("B5")
However I suspect that your problem is that "lookup_desksetup[[#All],[Getting your desk setup]]" is a very funny range name and may not actually exist as a valid name in that sheet?

Excel Macro Copy Paste REF! Error

I am currently new to excel macros and trying to figure out why this is not working. Basically, I want Cell "D22" from "Sheet1" to be copied and then pasted to "sheet2" Cell "A2". The problem is on sheet1 I have a formula in cell D22 so when I copy and paste it into the new sheet, I get a #REF! ERROR :(
I have looked it up and tried fixing it but still no luck. Below is my basic code. I know there is probably a simple solution but if someone could please advise me in the right direction much would be appreciated! xD
Sub Insert()
Sheets("Sheet1").Select
Range("D22").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A2").Select
ActiveSheet.Paste
End Sub
If you just want to assign the value of one cell to another, don't use copy/paste, just use the Value property:
Sub Insert()
Sheets("Sheet2").Range("A2").Value = Sheets("Sheet1").Range("D22").Value
End Sub

Excel Macro for checkbox if true

i need a macro or a line to add to my code for when the checkbox is true or "Checked" i need it to copy the content of a specific cell into another in a sheet in the same workbook what i was able to get to is this code
Sub macro2()
Range("A1:C4").Select
Selection.Copy
Sheets("sheet2").Select
Range("A1:C4").Select
ActiveCell.PasteSpecial
End Sub
but as you can see it only gets me to get this range to be copied and pasted once i have checked the box what i need is to copy it when checked and maybe not to let it get m to the cell in sheet2 to allow multiple selections to be pasted in some specified cells i know i have the code sheet2.select but i honestly don't know any other coding and i need to put that kind of coding for over hundred cells so do appreciate your assistance with this if anybody can please am dying here
If CheckBox1.Value = True Then
ThisWorkbook.Sheets("Sheet2").Range("A1:C4").Value = ThisWorkbook.Sheets("Sheet1").Range("A1:C4").Value
End if

VBA Code to copy and paste active column with merged cells inside

I'm trying to copy the active column and paste it next to it but the code selects the entire worksheet because it has merged cells in.
Sub CopyPaste()
Columns(ActiveCell.Column).Selection
Selection.Copy
ActiveCell.Offset(0,1).PasteSpecial Paste:=xlPasteAll
End Sub
Could you please help me adding the missing code to ignore merged cells?
This is yet another reason to avoid using Select in VBA for Excel. Your selection will expand with the merged cells. You can try this:
ActiveCell.EntireColumn.Copy ActiveCell.Offset(0, 1).EntireColumn
And again, you should find some way to avoid counting on the ActiveCell in your code, and use some fully qualified range.

Macro Copy&Paste

I'm trying to create a macro that will copy data from one worksheet and place into another. This I can do with no problem. But, when I want to use the same macro in another row is where I have my problem. Basically what I want to do is copy cell D11 from sheet1 and place that in cell B4 on sheet2, etc (What I'm doing is obviously more complicated than that, but that doesn't matter here).
My problem is when I want to now run this macro and copy cell D12 from sheet1 and paste into B5 on sheet2 the value pasted jumps to B4. I understand that this happens because of where the VBcode is saying to paste the copied value.
My question is how to I just have it paste in whatever row I choose? Maybe based on what row/cell I have selected.
Current code, written by recording the macro
Sheets("sheet1").Select
Range("D11").Select
Selection.Copy
Sheets("sheet2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B4").Select
I'm assuming the last line is where I need to make the change, but I'm not sure what to change.
Thank you! Any and all help is greatly appreciated.
As a general rule, try to avoid Selection Copy-Paste (detailed discussion is provided in: "Application.Calculation = xlCalculationManual" statement causing run-time error 1004 in VBA Copy-Paste procedure). Instead, use direct copy statement, which will solve you issue and significantly improve performance:
Listing 1.
Sub DirectCopySample()
Application.ScreenUpdating = False
Sheets("Sheet1").Range("D11").Copy Destination:=Sheets("Sheet2").Range("B5")
Application.ScreenUpdating = True
End Sub
Sub in Listing 1 performs direct copy from Cell: Sheets("Sheet1").Range("D11") into cell: Sheets("Sheet2").Range("B5").
Also, your initial Copy-Paste Sub could be simplified (it will also make it work, though Listing 1 is preferred)
Listing 2.
Sub CopyPasteSample()
Sheets("sheet1").Range("D11").Copy
Sheets("sheet2").Range("B5").PasteSpecial Paste:=xlPasteValues
End Sub
Hope this will help. Best regards,
You seem to have recorded a Macro and are trying to replay it. Here is a real VBA code (not a Macro recording type):
Sheets("sheet2").Range("B5") = Sheets("sheet1").Range("D11").Value
This is all!
BTW, your predicament comes from the fact that the PasteSpecial method copies into the currently selected cell. You've tried running this Macro several times and the Range("B4").Select line did the trick. If you insist on your approach the insert Range("B5").Select BEFORE the PasteSpecial.