I've been able to code a macro that does the following:
copy column A into Column B with format "mm-dd-yyyy".
copy column A into Column C with format "h:mm".
Now, I need to do the following, but I don't know how...
- Copy the newly created columns B,C, and each individual column to the right of the new columns into their own individual workbooks. I would like the workbooks to be named based on "current sheet title" and each individual row 2 name. As an example I have attached an image of the workbook data and what 1 sheets final product would look like.
I think the code would have to do the following: Create a range based column variable X and row 2. Then state that for each column X, if row 2 contains a value then copy column B, column C, and the current column X. Then paste the (3) columns (B,C, & Column Variable X) into a new workbook and name the workbook based on the "current sheet title + the cell name of current column X, row 2".
I appreciate anybody's help, please let me know if what I'm saying is confusing and I will try and clear it up.
Images:
Data: Data Image
Final Product 1: Final Product Image 1
Final Product 2:Final Product Image 2
Current Macro:
Sub Time_Series()
Dim CurrentSheet As Worksheet
With CurrentSheet
Range("A:A").Copy
Range("B:C").Insert
Range("B:B").NumberFormat = "mm-dd-yyyy;@"
Range("C:C").NumberFormat = "h:MM;@"
End With
End Sub
Range(Range("B2"), Range("B2").End(xlDown)).NumberFormat = "mm-dd-yyyy;@"
, also formatting wont remove the unused date part so if ever you sort/group etc what you are seeing through the for at mask is only part of the actual cell contents. – JohnnieLset ws = Thisworkbook.worksheets.add
will create a new workbook for you and using logic likeRange(Range("B2"), Range("B2").End(xlDown)).copy destination:= ws.range("a1")
will effect the copy – JohnnieL