OilEconomist
Active Member
- Joined
- Dec 26, 2016
- Messages
- 439
- Office Version
- 2019
- Platform
- Windows
Thanks in advance. After searching I have found sites to get part of what I would like, but nothing with the final values.
I have a column A which is empty and with range of cells from A8 to A & LastRow, where I determine the last row, I would like to extract the first 10 characters of Column D8 to D & LastRow but also number column A and then combine them in A.
I would like create a VBA Sub/Macro to get the current sheet (Table 1) to look like my final sheet (Table 2).
Table 1: This table has what I have now.
Table 2: I would like the final result to look like this:
VBA Code Start (not much, but wanted to include something to start with:
Option Explicit
I have a column A which is empty and with range of cells from A8 to A & LastRow, where I determine the last row, I would like to extract the first 10 characters of Column D8 to D & LastRow but also number column A and then combine them in A.
I would like create a VBA Sub/Macro to get the current sheet (Table 1) to look like my final sheet (Table 2).
Table 1: This table has what I have now.
Rows | Column A | Column D |
8 | 2020-10-01 @ 15:13 | |
9 | 2020-10-01 @ 16:19 | |
10 | 2020-10-02 @ 2:30 | |
11 | 2020-10-04 @ 5:30 | |
12 | 2020-10-05 @ 14:30 |
Table 2: I would like the final result to look like this:
Rows | Column A | Column D |
8 | 2020.10.01.0001 | 2020-10-01 @ 15:13 |
9 | 2020.10.01.0002 | 2020-10-01 @ 16:19 |
10 | 2020.10.02.0003 | 2020-10-02 @ 2:30 |
11 | 2020.10.04.0004 | 2020-10-04 @ 5:30 |
12 | 2020.10.05.0005 | 2020-10-05 @ 14:30 |
VBA Code Start (not much, but wanted to include something to start with:
Option Explicit
VBA Code:
Public Sub CmbCol()
'__________________________________________________________________________________________
'Turn off alerts, screen updates, and automatic calculation
'Turn off Display Alerts
Application.DisplayAlerts = False
'Turn off Screen Update
Application.ScreenUpdating = False
'Turn off Automatic Calculations
Application.Calculation = xlManual
'__________________________________________________________________________________________
'Dimensioning
Dim LastRow As Long
'__________________________________________________________________________________________
'Code
Sheets("Sheet1").Activate
LastRow = Cells(Rows.Count, "D").End(xlUp).Row
'_________________________________________________________________________________________________________________
'Turn on alerts, screen updates, and calculate
'Turn On Display Alerts
Application.DisplayAlerts = True
'Turn on Screen Update
Application.ScreenUpdating = True
'Turn off Automatic Calculations
Calculate
End Sub