copy (split) part of cell in one column into a new column

wittonlin

Board Regular
Joined
Jan 30, 2016
Messages
144
I have the following date/time in Column K
Mon Nov 14 20:15:14 EST 2016

I'd like to copy the first 3 parts 'Mon Nov 14' and add it to column R for all rows in a workbook with a variable file name.

Column K remains unchanged.

Thanks so much for anyone able to help!
 
I was hoping just removing that line would work. lol

.Rows(1).Value = "" 'This will clear out row


I'll also never need this line so I removed it too.

.Rows(1).Font.Bold = False
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Oops! I copied too much code in that you may have missed.

Rich (BB code):
Sub AddHeaders()
Dim headers() As Variant
Dim ws As Worksheet
Dim wb As Workbook

Application.ScreenUpdating = False 'turn this off for the macro to run a little faster

Set wb = ActiveWorkbook

headers() = Array("Firstname", "Lastname", "Mobile", "Timezone", "Address", "City", "State", "Zip", "Email", "IP", "Time and Date", _
    "Gender")
For Each ws In wb.Sheets
    With ws
    .Rows(1).Value = "" 'This will clear out row 1
    For i = LBound(headers()) To UBound(headers())
        .Cells(1, 1 + i).Value = headers(i)
    Next i
    .Rows(1).Font.Bold = False
    End With
Next ws

Application.ScreenUpdating = True 'turn it back on

End Sub

And really now just this...

Rich (BB code):
Sub AddHeaders()
Dim headers() As Variant
Dim ws As Worksheet
Dim wb As Workbook

Set wb = ActiveWorkbook

headers() = Array("Firstname", "Lastname", "Mobile", "Timezone", "Address", "City", "State", "Zip", "Email", "IP", "Time and Date", _
    "Gender")
For Each ws In wb.Sheets
    With ws
    For i = LBound(headers()) To UBound(headers())
        .Cells(1, 1 + i).Value = headers(i)
    Next i

    End With
Next ws

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,756
Messages
6,132,530
Members
449,733
Latest member
Nameless_

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