domex
Board Regular
- Joined
- Feb 25, 2010
- Messages
- 144
Hi Guys,
Im using the below given macro to sort data from column A, from first sheet then split the sorted data into other sheet.
Now the problem is when column A contains huge data on specifc sort it takes very long time.
For e.g. If i sort column A as Apple the result is around 5000 rows then it creates the new sheet as apple and paste the data from sorted column but when the no is huge it take soooooooooo long time.
Kindly modify the macro to save my time.
My requirement is just sort data from column A one by one then paste it into other worksheets then rename the sheet.
Thanks in Advance.
Please let me know if you require any clarification.
Ranjith
Im using the below given macro to sort data from column A, from first sheet then split the sorted data into other sheet.
Now the problem is when column A contains huge data on specifc sort it takes very long time.
For e.g. If i sort column A as Apple the result is around 5000 rows then it creates the new sheet as apple and paste the data from sorted column but when the no is huge it take soooooooooo long time.
Kindly modify the macro to save my time.
My requirement is just sort data from column A one by one then paste it into other worksheets then rename the sheet.
Thanks in Advance.
Code:
Option Explicit
Sub Splitdatatosheets()
'
' Splitdatatosheets Macro
'
'
Dim rng As Range
Dim rng1 As Range
Dim vrb As Boolean
Dim sht As Worksheet
Set rng = Sheets("Sheet1").Range("A4")
Set rng1 = Sheets("Sheet1").Range("A4:R4")
vrb = False
Do While rng <> ""
For Each sht In Worksheets
If sht.Name = rng.Value Then
sht.Select
Range("A2").Select
Do While Selection <> ""
ActiveCell.Offset(1, 0).Activate
Loop
rng1.Copy ActiveCell
ActiveCell.Offset(1, 0).Activate
Set rng1 = rng1.Offset(1, 0)
Set rng = rng.Offset(1, 0)
vrb = True
End If
Next sht
If vrb = False Then
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = rng.Value
Sheets("Sheet1").Range("A3:R3").Copy ActiveSheet.Range("A1")
Range("A2").Select
Do While Selection <> ""
ActiveCell.Offset(1, 0).Activate
Loop
rng1.Copy ActiveCell
Set rng1 = rng1.Offset(1, 0)
Set rng = rng.Offset(1, 0)
End If
vrb = False
Loop
End Sub
Ranjith