I write Cobol format in VBA excel please help me with such as?

Faozan

Banned user
Joined
May 14, 2023
Messages
25
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
  6. 2011
  7. 2010
  8. 2007
  9. 2003 or older
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
Such as asdfghjk =>asd-fg-hijk (alphanumeric)
1234567 => 12-345-67 (numeric)
 
Code:
Sub Here_We_Go()
Dim c As Range
    For Each c In Sheets("Sheet1").Range("C2:C" & Sheets("Sheet1").Cells(Rows.Count, 3).End(xlUp).Row)
        If IsNumeric(c.Value) Then
            With Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Offset(1)
                .NumberFormat = "@"
                .Value = Left(c, 4) & ".00" & "-" & Mid(c, 5, 3) & ".00" & "-" & Mid(c, 8) & ".00"
            End With
        Else
            With Sheets("Sheet3").Cells(Rows.Count, 1).End(xlUp).Offset(1)
                .Value = Left(c, 2) & "-" & Mid(c, 3, 2) & "-" & Mid(c, 5)
            End With
        End If
    Next c
End Sub

What I mean by Post #18 is to NOT use the quote button.
If refer post number and then round decimal after . Such as 1.77 to 2.00
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

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