Concatenate 2 cells from Sheet1 to 1 cell Sheet2

Tmcc

EDIT: Found the stray code that threw it off. Thanks everyone!

I've been trying to figure out the code to concatenate

Worksheets("Sheet1").Range ("B2:C2")

to this reference cell with " - " character as a separator:

Worksheets("Sheet2").Range ("B2")

I've tried the following, but it says "subscript out of range":

Worksheets("Sheet2").Range("B2").Cell.Value = 
  Worksheets("Sheet1").Range("B2").Cell.Value & 
    Worksheets("Sheet1").Range("C2").Cell.Value

I've also tried this, but it only copies Sheet1.C2 to Sheet2.C2:

Set sourceRange = Worksheets("Sheet1").Range("B2:C2")
Set targetRange = Worksheets("Sheet2").Range("B2")

sourceRange.Copy
targetRange.PasteSpecial Paste:=xlPasteValues

Any help on this would be appreciated. Thanks in advance!

Máté Juhász

You've extra cells

Worksheets("Sheet2").Range("B2").Value = Worksheets("Sheet1").Range("B2").Value & Worksheets("Sheet1").Range("C2").Value

Should work.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Copying cells from sheet1 to sheet2 if it does not exist in sheet2

From Dev

Automatically Copy cells from Sheet2 to Custom column on Sheet1 with rule

From Dev

How to run a macro in sheet1 from sheet2

From Dev

How To copy data from a range in sheet1 to sheet2 5 times until I reach an empty cell?

From Dev

Copying active row of Sheet1 to Sheet2 based on cell condition & avoid duplicates

From Dev

How to iterate through rows in sheet1 given cell value in sheet2 and replace row in sheet1 with row in sheet 2?

From Dev

excel compare current time value from sheet1 to time value range from sheet2

From Dev

Copying data based on the headers from Sheet1 to Sheet2

From Dev

Refer data from sheet2 to sheet1 dynamically based on date

From Dev

Copying columns in Excel from sheet1 to sheet2 without having to cut and paste

From Dev

Excel Online - Replicate date from sheet1 columnA to sheet2 columnB

From Dev

Copying data based on the headers from Sheet1 to Sheet2

From Dev

How to update existing data from Sheet1 to Sheet2 using Macro?

From Dev

Excel 2010 : Copy block of cells from sheet 2 > sheet1 based on criteria

From Dev

Getting the last fillled column in a sheet1 and copying the data in sheet2 to sheet1

From Dev

Copy Range Sheet1 Paste in Active Cell Sheet 2

From Dev

Excel: Trying to consolidate weighted average data from Sheet1 and summarize to Sheet2 when Sheet 1 has variable number of rows

From Dev

Run A Macro on Each Sheet Except Sheet1 and Sheet2

From Dev

I need to match Sheet1 Column A to Sheet2 Column A if they match then copy Sheet2 Column B to Sheet1 Column I

From Dev

Excel: how to sum values in sheet2 based on whether a value in sheet1 matches value in sheet2

From Dev

Create columns in sheet2 depending on number of rows in sheet1 in excel

From Dev

VBA - Check a range in sheet1 for a variable and create a list on sheet2 of each occurence of the variable

From Dev

search all rows and columns in sheet1 for string, copy entire row to sheet2 if found

From Dev

How to reflect sheet1's those rows only which contains positive values, into sheet2?

From Dev

Copy Row if Sheet1 A contains part of Sheet2 C

From Dev

Excel VBA-Find string in sheet2 and copy the this in sheet1

From Dev

Validate if a Prefix in sheet2 has a matching value in sheet1

From Dev

MS Excel partial match sheet1!A1 with sheet2!A1 return sheet2!B1

From Dev

Copy the most recently updated cells from sheet 1 to sheet 2

Related Related

  1. 1

    Copying cells from sheet1 to sheet2 if it does not exist in sheet2

  2. 2

    Automatically Copy cells from Sheet2 to Custom column on Sheet1 with rule

  3. 3

    How to run a macro in sheet1 from sheet2

  4. 4

    How To copy data from a range in sheet1 to sheet2 5 times until I reach an empty cell?

  5. 5

    Copying active row of Sheet1 to Sheet2 based on cell condition & avoid duplicates

  6. 6

    How to iterate through rows in sheet1 given cell value in sheet2 and replace row in sheet1 with row in sheet 2?

  7. 7

    excel compare current time value from sheet1 to time value range from sheet2

  8. 8

    Copying data based on the headers from Sheet1 to Sheet2

  9. 9

    Refer data from sheet2 to sheet1 dynamically based on date

  10. 10

    Copying columns in Excel from sheet1 to sheet2 without having to cut and paste

  11. 11

    Excel Online - Replicate date from sheet1 columnA to sheet2 columnB

  12. 12

    Copying data based on the headers from Sheet1 to Sheet2

  13. 13

    How to update existing data from Sheet1 to Sheet2 using Macro?

  14. 14

    Excel 2010 : Copy block of cells from sheet 2 > sheet1 based on criteria

  15. 15

    Getting the last fillled column in a sheet1 and copying the data in sheet2 to sheet1

  16. 16

    Copy Range Sheet1 Paste in Active Cell Sheet 2

  17. 17

    Excel: Trying to consolidate weighted average data from Sheet1 and summarize to Sheet2 when Sheet 1 has variable number of rows

  18. 18

    Run A Macro on Each Sheet Except Sheet1 and Sheet2

  19. 19

    I need to match Sheet1 Column A to Sheet2 Column A if they match then copy Sheet2 Column B to Sheet1 Column I

  20. 20

    Excel: how to sum values in sheet2 based on whether a value in sheet1 matches value in sheet2

  21. 21

    Create columns in sheet2 depending on number of rows in sheet1 in excel

  22. 22

    VBA - Check a range in sheet1 for a variable and create a list on sheet2 of each occurence of the variable

  23. 23

    search all rows and columns in sheet1 for string, copy entire row to sheet2 if found

  24. 24

    How to reflect sheet1's those rows only which contains positive values, into sheet2?

  25. 25

    Copy Row if Sheet1 A contains part of Sheet2 C

  26. 26

    Excel VBA-Find string in sheet2 and copy the this in sheet1

  27. 27

    Validate if a Prefix in sheet2 has a matching value in sheet1

  28. 28

    MS Excel partial match sheet1!A1 with sheet2!A1 return sheet2!B1

  29. 29

    Copy the most recently updated cells from sheet 1 to sheet 2

HotTag

Archive