Concatenate 1st part of string in single cell

Padawan

Active Member
Joined
Apr 9, 2002
Messages
395
Greetings, All

I'm trying to enter the last 5 digits of a number & have Excel concatenate the first 4 characters/digits of the number based on another cell.

For example, the desired output = 11-22-04-005

The 1st part is selected from a drop down, 11-22 (I can use helper cells for this if needed)

I want to be able to type in 04005 and when I hit enter the cell contains 11-22-04-005.
Can't use any helper cells for entering the 04005
.
Not sure if I want data validation, VBA, both or something else.

Thoughts?

THANK YOU
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I would think this would be a VBA thing, but we need more specific details to come up with code for you.

Where exactly is this drop-down with the "11-22" located (what is the cell address)?
What happens if a value hasn't been selected yet?

Where are these 5 digits numbers being entered, exactly?
Does it always have to be exactly 5 characters?
 
Upvote 0
Joe4,

APOLOGIES for not getting back to you sooner. I appreciate the time you took to reply and am sorry that it felt like I blew you off. Did not intend that.

After I posted my question, I realized I could use a Worksheet change event. So to resolve this question, here is my solution.

My target cells are in range B20 - B119
The current year (2022) is in cell E7
A 2-digit ID number (ie 03) is in cell AC7
The user enters a 2 digit office code, ie 08 and a 3 digit sequence number ie 007

The result I want is for the VBA to append the year, ID number, office code and sequence number.
So for my example, the user enters 08007 and I want the vba to enter 22-03-08-007 in the target/active cell.

The code I used is a worksheet change event

If intersect(Target, Range("B20:B119") Is Nothing Then GoTo NextStep

Application.EnableEvents = False

For Z = 1 to Target.Count
If Target(Z).Value>0 Then
Target(Z).Value = Right (Range("E7"),2) & "-" & Range("AC7") & "-" & Left (Target(Z).Value,2 & "-" & Right(Target(Z).Value),3)
End If
Next
End If




There's other code as well, but this is the portion relevant to my question.
Thank you again for the quick response to my original post.

Work
 
Upvote 0
Solution

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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