Quantcast
Channel: Microsoft Community - Super Fresh
Viewing all articles
Browse latest Browse all 1237235

VBA to split data based on row value

$
0
0

Hi

i need to split data based on row value , i have written a code that can split data ,but problem is that my code just split based on a simple row value i.e if i have in column v Nauman in multiple rows my code create a new tab with nauman name in copy data into it 

but i have splitting criteria is very complex such as Nauman/Bob// something like that . as in my screen shot , i just need to create 4 sheets with Name 

Anthony Kovach
Hector Cruz
Paul Sinatra
Tim McGowen

you must see a red line that's mean sheet data should be transfered to both tab  name, under is my code so far

Sub test()
Dim Src As Worksheet
Set Src = Sheets("WIP")
Dim sh As Worksheet
On Error Resume Next
x = 3
    Do While Len(Src.Range("V" & x).Text) > 0
        Set sh = Sheets(Src.Range("V" & x).Text)
        If Err.Number = 9 Then
            Sheets.Add.Name = Sheets("WIP").Range("V" & x)
            Set sh = Sheets(Src.Range("V" & x).Text)
            Src.Range("A2:V2").Copy sh.Range("A1")
        Err.Clear
        End If
        x = x + 1
        lr = sh.Range("A" & sh.Cells.Rows.Count).End(xlUp).Row + 1
        Src.Range("A" & x & ":V" & x).Copy sh.Range("A" & lr)
       
       
    Loop
On Error GoTo 0
End Sub

regards


Viewing all articles
Browse latest Browse all 1237235

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>