Hi,
I need some help adding a loop to an existing code and can't figure it out. Newbie here.
Current: I have a single cell (a9), that has hundreds of results. Each result has a carriage return after it. I need each result to be split out having their own row.
The current code basically does a text to columns and then a transposes the data in column A starting with cell A9.
Requested help:
1. I would like to have this code to loop and execute on specific sheets only. (in particular sheets 11-18)
2. Instead of the resulting data starting in A9, I would like the resulting data to start in G1, or a cell on a summary sheet.
3. Finally, it would be nice if the result removed the blank rows between the earnings.
Any help you could provide would be wonderful. Thank you!!
D
Code that doesn't work today: It breaks at sh.[a9] because I don't know what to do at that point.
Sub Loopforselectsheetsonly()
Dim sh As Worksheet
For Each sh In Sheets
' This starts the VBA loop to execute the VBA split only on assigned Sheets
Select Case sh.Name
Case Is = "Sheet11", "Sheet12", "Sheet13"
sh.[a9].
'Not sure what this does. Need this to execute on the below code, then loop back and do it on all assigned sheets.
End Select
Next sh
End Sub
Sub Splitcelldatawithcarriagereturn()
'VBA code to split out cell that has countless data with carriage returns
'Separates on carriage return, then transposes data. Result = vertical list
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
Set WorkRng = Range("a9")
For Each Rng In WorkRng
lLFs = VBA.Len(Rng) - VBA.Len(VBA.Replace(Rng, vbLf, ""))
If lLFs > 0 Then
Rng.Offset(1, 0).Resize(lLFs).Insert shift:=xlShiftDown
Rng.Resize(lLFs + 1).Value = Application.WorksheetFunction.Transpose(VBA.Split(Rng, vbLf))
End If
Next
End Sub
I need some help adding a loop to an existing code and can't figure it out. Newbie here.
Current: I have a single cell (a9), that has hundreds of results. Each result has a carriage return after it. I need each result to be split out having their own row.
The current code basically does a text to columns and then a transposes the data in column A starting with cell A9.
Requested help:
1. I would like to have this code to loop and execute on specific sheets only. (in particular sheets 11-18)
2. Instead of the resulting data starting in A9, I would like the resulting data to start in G1, or a cell on a summary sheet.
3. Finally, it would be nice if the result removed the blank rows between the earnings.
Cell | Data |
A9 | Earning 1 Earning 2 Earning 3 |
Any help you could provide would be wonderful. Thank you!!
D
Code that doesn't work today: It breaks at sh.[a9] because I don't know what to do at that point.
Sub Loopforselectsheetsonly()
Dim sh As Worksheet
For Each sh In Sheets
' This starts the VBA loop to execute the VBA split only on assigned Sheets
Select Case sh.Name
Case Is = "Sheet11", "Sheet12", "Sheet13"
sh.[a9].
'Not sure what this does. Need this to execute on the below code, then loop back and do it on all assigned sheets.
End Select
Next sh
End Sub
Sub Splitcelldatawithcarriagereturn()
'VBA code to split out cell that has countless data with carriage returns
'Separates on carriage return, then transposes data. Result = vertical list
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
Set WorkRng = Range("a9")
For Each Rng In WorkRng
lLFs = VBA.Len(Rng) - VBA.Len(VBA.Replace(Rng, vbLf, ""))
If lLFs > 0 Then
Rng.Offset(1, 0).Resize(lLFs).Insert shift:=xlShiftDown
Rng.Resize(lLFs + 1).Value = Application.WorksheetFunction.Transpose(VBA.Split(Rng, vbLf))
End If
Next
End Sub