0

can someone please help me on this code which i have been having trouble to do for the past 2 days. What i need to do is find the last column in that specific row starting from Column C and onwards if there's any text which i have managed to find but it only does it for the first row as i can't seem to find the code to go to the next row and repeat the action; the order it should work in is by going to the last cell in that column of that row and go left and when it find text in a cell it will then insert a row below it and cut and paste the text into the below row in column B. This will continue on until all the cells from C and onwards don't contain any text and move on to the next Row repeating the above action.

Sub newcode_eachline()
Dim datacheck as Range
Dim valuecell As String
Dim cell As Range


Range("A1").Select


Do
Set datacheck = Range(ActiveCell.Offset(0, 2), ActiveCell.Offset(0, 2).End(xlToRight))

For Each cell In datacheck

If cell <> "" Then
ActiveCell.Select
valuecell = Cells(Columns.Count).End(xlToLeft).Select


  
ActiveCell.Offset(1, 0).EntireRow.Insert shift:=xlDown
ActiveCell.Select
Selection.Cut

ActiveCell.Offset(1, 0).End(xlToLeft).Select
ActiveCell.Offset(0, 1).Select
ActiveSheet.Paste

    ActiveCell.Offset.End(xlToLeft).End(xlUp).Select
    
    
    
Else
Do
ActiveCell.Offset(1, 0).Select
Loop Until ActiveCell.Offset(0, 0) <> ""

End If



Next
Loop Until ActiveCell.Offset(0, 0).End(xlDown).Value = ""
End Sub

The "Do Set datacheck = Range(ActiveCell.Offset(0, 2), ActiveCell.Offset(0, 2).End(xlToRight)) For Each cell In Datacheck," doesn't seem to work properly and i can't seem to find a solution to check from C and all the way to the last column cell if there's any text in that range and the Valuecell = Cells(Columns.Count).End(xlToLeft).Select which only targets the first row.

Much appreciated if someone can help me out with this and let me know.

enter image description here

End Result

braX
  • 11,506
  • 5
  • 20
  • 33
Rj M
  • 33
  • 1
  • 4
  • Read https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba for starters. What should the results be? – SJR Jun 23 '20 at 17:21
  • For the first row I need all the cells with data in after column B should be under the 5alpha 5numeric code in Column B (grtjil74854). The end result for the first row, Column B(B1 - grtjil74854 , B2 -grtjil74852, B3 - grtjil74853, B4 - grtjil74854) I need the blank cells in column A for each data that's been added in the row below. Same outcome for row 5 and 11. Hope that helps. – Rj M Jun 23 '20 at 21:19

0 Answers0