Need repair in code...

VBABEGINER

Well-known Member
Joined
Jun 15, 2011
Messages
1,284
Office Version
  1. 365
Platform
  1. Windows
Hello All,

I have new query..in col J i have date. in col I i have some Text's..
Col I
Code:
CG D2 42
GN 01 82

Col J
Code:
1/1/2002
12/1/2014

I'm trying to use concatenate this two...in col H. But in my "left" code, it picks up "1" instead of "01"...
and hence giving me a wrong output..like..
Code:
CG D2 42 - 1//2002

I want to Text + month (from date) i.e. 1st 02 digit + Year (from date)

this is my code..
Code:
Range("G1").Select
Dim RowCnt5 As Integer
RowCnt5 = Range("G3").End(xlDown).Row
    For m = 2 To RowCnt5
        Cells(m, "H").Value = Cells(m, "I") & " - " & Left(Cells(m, "J"), 2) & "/" & Right(Cells(m, "J"), 4)
    Next m


can any one pls fix this..
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
I want to Text + month (from date) i.e. 1st 02 digit + Year (from date)

this is my code..
Code:
Range("G1").Select
Dim RowCnt5 As Integer
RowCnt5 = Range("G3").End(xlDown).Row
    For m = 2 To RowCnt5
       [B][COLOR="#FF0000"] Cells(m, "H").Value = Cells(m, "I") & " - " & Left(Cells(m, "J"), 2) & "/" & Right(Cells(m, "J"), 4)[/COLOR][/B]
    Next m

can any one pls fix this..
Try replacing the red highlighted line of code with this one and see if that works for you...
Code:
[table="width: 500"]
[tr]
	[td]Cells(m, "H").Value = Cells(m, "I") & " - " & Format(Cells(m, "J"), "mm/yyyy")[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,912
Messages
6,175,340
Members
452,638
Latest member
Oluwabukunmi

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