Forum Discussion
dlucas980
Jul 01, 2020Copper Contributor
Extracting date
I have a worksheet that includes client account information such as Client Name, Client Address, Account Number, Account Balance, Date Opened, Date Closed, etc. This information is collected in colu...
Subodh_Tiwari_sktneer
Jul 02, 2020Silver Contributor
If you are open to a VBA solution, you may try something like this...
Sub SplitDataToSheets()
Dim wsData As Worksheet
Dim dws As Worksheet
Dim shName As String
Dim lr As Long
Dim lc As Long
Dim Rng As Range
Dim str As Variant
Dim acRng As Range
Dim dtRng As Range
Application.ScreenUpdating = False
Set wsData = Worksheets("Master")
lr = wsData.Cells(Rows.Count, 1).End(xlUp).Row
lc = wsData.Cells(2, Columns.Count).End(xlToLeft).Column
For Each Rng In wsData.Rows(2).SpecialCells(xlCellTypeConstants, 2).Areas
str = Split(Rng.Value, Chr(10))
shName = str(0) & " Account"
Set acRng = wsData.Range(wsData.Cells(Rng.Row + 1, 1), wsData.Cells(lr, 1))
Set dtRng = wsData.Range(wsData.Cells(Rng.Row + 1, Rng.Column), wsData.Cells(lr, Rng.Column + 1))
On Error Resume Next
Set dws = Worksheets(shName)
dws.Cells.Clear
On Error GoTo 0
If dws Is Nothing Then
Set dws = Worksheets.Add(after:=Worksheets(Worksheets.Count))
dws.Name = shName
End If
dws.Range("B2").Value = Rng.Value
acRng.Copy dws.Range("B3")
dtRng.Copy dws.Range("C3")
dws.Range("A3").Value = "#"
dws.UsedRange.RowHeight = 15
With dws.Range("A4:A" & lr)
.Formula = "=Row()-3"
.Value = .Value
End With
With dws.Range("B2:D2")
.Merge
.Font.Bold = True
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.RowHeight = 50
End With
dws.UsedRange.Columns.AutoFit
Set dws = Nothing
Next Rng
wsData.Select
Application.ScreenUpdating = True
End Sub
In the attached, click the button called "Split Accounts" on Master Sheet.
dlucas980
Jul 02, 2020Copper Contributor
Thank you. I have never used VBA. But, I am willing to try. If nothing else, I will learn something about VBA.
Thank you.
Thank you.