How to copy data from one cell to another in Excel using if formula

Formula-to-Copy-Cell-Value-to-Another-Cell-in-ExcelDownload File

To copy one cell to another is very easy, you just have to make a reference to the cell you want to copy.

Copy cell value to another cell

For example, to copy cell A2 to C2, enter =A2 in C2.

How to copy data from one cell to another in Excel using if formula

Copy cell value from another sheet

You can also do it with the value that is present on another sheet.

How to copy data from one cell to another in Excel using if formula

Copy and paste the specific value to different cell

This VBA function will work in the following way.

The following function will check whether a cell contains text, numerical value, error, or formula.

Function CopyCell(ByVal target As Range, cellType As String) If target.HasFormula And cellType = "formula" And Not IsError(target.Value) Then CopyCell = target ElseIf Application.IsText(target.Value) And cellType = "string" Then CopyCell = target ElseIf IsNumeric(target.Value) And cellType = "number" Then CopyCell = target ElseIf IsError(target.Value) And cellType = "error" Then CopyCell = target Else CopyCell = "" End If End Function

Function CopyCell(ByVal target As Range, cellType As String)

    If target.HasFormula And cellType = "formula" And Not IsError(target.Value) Then

    ElseIf Application.IsText(target.Value) And cellType = "string" Then

    ElseIf IsNumeric(target.Value) And cellType = "number" Then

    ElseIf IsError(target.Value) And cellType = "error" Then

The function checks a few conditions and if a condition is met it copies the cell, otherwise it places a blank cell.

The function has a few modifications. For example, under formulas, I added a condition, that it won’t display errors (which are also formulas).

You might also consider not copying the value in cell E4 because it’s formatted as text.

Enter the following formulas into cells:

C2: =CopyCell(A2,”formula”)

D2: =CopyCell(A2,”string”)

E2: =CopyCell(A2,”number”)

F2: =CopyCell(A2,”error”)

How to copy data from one cell to another in Excel using if formula

Press Ctrl + ~ to display formulas.

How to copy data from one cell to another in Excel using if formula

For automatically copying and pasting cell value within current sheet or from one sheet to another without using the shortcut keys, this article can help you.

Auto copy and paste cell in current sheet or from one sheet to another with formula
Auto copy and paste cell in current sheet with VBA
Copy and paste multiple ranges in current sheet or from one sheet to another with Kutools for Excel

Auto copy and paste cell in current sheet or from one sheet to another with formula

You can use formula to copy and paste cell automatically. Please do as follows.

1. For copying and pasting cell in current sheet such as copy cell A1 to D5, you can just select the destination cell D5, then enter =A1 and press the Enter key to get the A1 value.

2. For copying and pasting cell from one sheet to another such as copy cell A1 of Sheet1 to D5 of Sheet2, please select the cell D5 in Sheet2, then enter =Sheet1!A1 and press the Enter key to get the value.

Tips: The destination cell is linked to the copied cell, and it will be changed as the original cell changes.

Auto copy and paste cell in current sheet with VBA

The following VBA code helps you copy a cell or a range of cells and paste to specified cells in current worksheet.

1. Press Alt + F11 keys simultaneously to open the Microsoft Visual Basic for Applications window.

2. In the Microsoft Visual Basic for Applications window, click Insert > Module. Then copy and paste the below VBA code into the Module window.

VBA code: Auto copy and paste cell in current sheet

Sub RangeTest() On Error Resume Next Dim xRg As Range Set xRg = Application.Selection Range("A1 ").Copy Range("D5") xRg.Select End Sub

Note: In the code, A1 is the cell you will copy, and D5 is the destination cell of placing the value of cell A1. For auto copy and paste cell range, please replace the cell with range, such as replace A1 with A1:A10, and replace D5 with D1:D10.

3. Press the F5 key to run the code, then the certain cell (range) will be copied and pasted to a specified cell (range) automatically as well as the cell formatting.

Copy and paste multiple ranges in current sheet or from one sheet to another with Kutools for Excel

If you have multiple ranges to be copied at the same time, you can try the Copy Ranges utility of Kutools for Excel.

1. Select multiple ranges you need to copy with holding the Ctrl key. Then click Kutools > Copy Ranges. See screenshot:

How to copy data from one cell to another in Excel using if formula

2. In the Copy Multiple Ranges dialog box, you can see the selected ranges are listed in the Ranges to be copied box. Then specify an option in the Paste special section, check the Including row height or the Including column width box as you need, and finally click the OK button. See screenshot:

How to copy data from one cell to another in Excel using if formula

3. In the second Copy Multiple Ranges dialog box, specify a blank cell for pasting the selected ranges, and then click the OK button.

How to copy data from one cell to another in Excel using if formula

Note: if you want to paste the selected ranges to another sheet, please select the cell in that sheet and click the OK button in the second Copy Multiple Ranges dialog box.

Now the selected ranges are copied and pasted to the specified location.

Copy and paste multiple ranges in current sheet or from one sheet to another

Related articles:

Comments (1)

No ratings yet. Be the first to rate!