hi Pascal....
 
Thanku so much....it really helped me....appreciate your help.....& even it 
increased my knowledge in VB...
plz explain below part of code...& thanks again
 
If rCol > 1 Then 
            v = Array(r)
            .Rows(i + 1 & ":" & i + rCol - 1).Insert
            
            .Range(.Cells(i, 1), .Cells(i, 7)).Copy .Range(.Cells(i + 1, 
1), .Cells(i + rCol - 1, 7))
            
            .Range(.Cells(i, 8), .Cells(i + rCol - 1, 8)).Value = _

On Saturday, July 21, 2012 9:05:09 PM UTC+5:30, bpascal123 wrote:

>
> This line should allow you to run this macro from the workbook where the 
> data is ... if the file is not xlsx (it can then be xls, xlsm, xlsb ) 
> Set wbIn = ThisWorkbook
>
> (the line...worksheet add... that was commented out i forgot to delete 
> wouldn't work anyway-i just found it easier to run the code directly on the 
> splitted data sheet)
>
> and one more change in the complete code below (with method was missing in 
> what i sent previously):
>
> ---
>  Sub SGTest()
>
> Dim wbIn As Workbook
> Dim wsIn As Worksheet
> Dim wsInOut As Worksheet
> Dim v() As Variant
> Dim r As Range
> Dim rCol As Integer
> Dim i As Long, j As Long
> Dim lastr As Long, lastc As Long
>
> Set wbIn = ThisWorkbook
> Set wsInOut = wbIn.Worksheets("sorted data")
> Set wsIn = wbIn.Worksheets("splitted data")
>
> With Application
>     .Calculation = xlCalculationManual
>     .DisplayAlerts = False
>     .ScreenUpdating = False
> End With
>
> With wsIn
>
> lastc = 0
> .Rows(1).Copy wsInOut.Rows(1)
> lastr = .Cells(Rows.Count, 8).End(xlUp).Row
>
>     For i = lastr To 2 Step -1
>     
>         Set r = .Range(.Cells(i, 8), .Cells(i, 
> .Columns.Count).End(xlToLeft))
>         rCol = r.Columns.Count
>         
>         If rCol > 1 Then
>             v = Array(r)
>             .Rows(i + 1 & ":" & i + rCol - 1).Insert
>             
>             .Range(.Cells(i, 1), .Cells(i, 7)).Copy .Range(.Cells(i + 1, 
> 1), .Cells(i + rCol - 1, 7))
>             
>             .Range(.Cells(i, 8), .Cells(i + rCol - 1, 8)).Value = _
>             Application.WorksheetFunction.Transpose(v)
>             
>             If rCol > lastc Then lastc = rCol
>             
>         End If
>         
>     Next i
>     
>     lastr = .Cells(Rows.Count, 8).End(xlUp).Row
>     .Range(wsIn.Cells(1, 9), .Cells(lastr, lastc + 9)).ClearContents
>
> End With
>
>
> With Application
>     .Calculation = xlCalculationAutomatic
>     .DisplayAlerts = True
>     .ScreenUpdating = True
> End With
>
> Set r = Nothing
> Set wbIn = Nothing
> Set wsIn = Nothing
> Set wsInOut = Nothing
>
> End Sub
>
> ---
> Pascal
>
>
> On Friday, July 20, 2012 2:34:04 PM UTC+1, SG wrote: 
>>
>> hi pascal,
>>  
>> i didn't understand this part of code...what should i write if i run this 
>> macro in new workbook
>>  
>>  Set wbIn = Workbooks("Book1 - Copy.xlsm")
>> 'Set wsInOut = wbIn.Worksheets.Add: wsInOut.Name = "sorted data ok2"
>> Set wsInOut = wbIn.Worksheets("sorted data")
>> Set wsIn = wbIn.Worksheets("splitted data")
>>
>

-- 
-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to [email protected]

To unsubscribe, send a blank email to [email protected]


Reply via email to