Data from 2 cells into one, with specific format

happydonut

Board Regular
Joined
Nov 28, 2019
Messages
57
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have this code to add the value from two cells into one;
VBA Code:
Range("C1").Value = Range("A1").Value & " " & Range("B1").Value

The cell in A1 has a date, e.g. 2021-01-25
The cell in B1 has a number, e.g. 123456789
Goal is to have the value in C1 as MMDD from cell A1 followed by the value in B1, e.g. 0125 123456789

Questions:
1. How do I format the C1 to get the value there as explained?
2. In real life, there could be many rows in A1 (all dates) and B1 (all numbers). How can I make a code that takes all rows into consideration, e.g. A2+B2=C2, A3+B3=C3 etc until last row with a value?

Thanks.
 
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hi, would that change the date in A1 into the required format of MMDD?
If A1 is yet well formated the cell Text property is the way to go. If not - so I misread - it must be your way …​
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top