Correct Anand,

By mistake, i have left Exit sub in Code.

You can abbreviate code by using For Next loop

Sub collatedata()
Dim i%, j%
Dim rng As Range
Dim sh As Worksheet
Set sh = Sheets.Add
sh.Move after:=Sheets(Sheets.Count)
sh.Name = "Mastersheet"
Sheets(1).Range("A1:C1").Copy sh.Cells(1, 1)
For i = 1 To Sheets.Count
j = sh.Cells(Rows.Count, "A").End(xlUp).Row + 1
Sheets(i).Range("a2:c" & Sheets(i).Cells(Rows.Count, 3).End(xlUp).Row).Copy
sh.Cells(j, 1)
Next i
End Sub



On Thu, Dec 27, 2012 at 9:24 AM, Anand Kumar <anand...@gmail.com> wrote:

> Dear Noorain,
>
> In your code the statement Exit Sub comes right before End Sub. It is also
> not based on any condition being tested and no Error Handling is there so
> Go To is also not being used.
> Could you please explain how this code is working?
>
> Warm Regards,
> Anand Kumar
>
>
> On Thursday, 20 December 2012 12:45:09 UTC+5:30, NOORAIN ANSARI wrote:
>
>> Dear Pravin,
>>
>> Pls try, hope it will help to you.
>>
>> Sub collatedata()
>> Dim i As Integer
>> Dim j As Integer
>> Dim rng As Range
>> Dim sh As Worksheet
>> Set sh = Sheets.Add
>> sh.Move after:=Sheets(Sheets.Count)
>> sh.Name = "Mastersheet"
>> Sheets(1).Range("A1:C1").Copy sh.Cells(1, 1)
>> i = 1
>> Do While i <= Sheets.Count - 1
>> j = sh.Cells(Rows.Count, "A").End(xlUp).Row + 1
>> Sheets(i).Range("a2:c" & Sheets(i).Cells(Rows.Count,
>> 3).End(xlUp).Row).Copy sh.Cells(j, 1)
>> i = i + 1
>> Loop
>> Exit Sub
>> End Sub
>>
>>
>> On Thu, Dec 20, 2012 at 12:39 PM, Pravin Gunjal <isk...@gmail.com> wrote:
>>
>>> Hi Friends,
>>>
>>> I have an excel file containing almost 50 sheets in it and would like
>>> to gather all those data in a single sheet one after one (column headings
>>> may be different)
>>>
>>> Is there any way/VB code which can do it faster.  Thank you,
>>>
>>> Regards
>>> Pravin Gunjal.
>>>
>>>  --
>>> Join official Facebook page of this forum @ https://www.facebook.com/**
>>> discussexcel <https://www.facebook.com/discussexcel>
>>>
>>> FORUM RULES
>>>
>>> 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) Jobs posting is not allowed.
>>> 6) Sharing copyrighted material and their links is not allowed.
>>>
>>> NOTE : Don't ever post confidential data in a workbook. Forum owners and
>>> members are not responsible for any loss.
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "MS EXCEL AND VBA MACROS" group.
>>> To post to this group, send email to excel-...@googlegroups.com.
>>> To unsubscribe from this group, send email to excel-macros...@**
>>> googlegroups.com.
>>>
>>> Visit this group at 
>>> http://groups.google.com/**group/excel-macros?hl=en<http://groups.google.com/group/excel-macros?hl=en>
>>> .
>>>
>>>
>>>
>>
>>
>>
>> --
>> With Regards,
>> Noorain Ansari
>> http:// 
>> <http://www.noorainansari.com>noorainansari.com<http://www.noorainansari.com>
>> http:// 
>> <http://www.excelvbaclinic.blogspot.com>excelvbaclinic.com<http://www.excelvbaclinic.blogspot.com><http://accesssqclinic.blogspot.in/>
>>
>>  --
> Join official Facebook page of this forum @
> https://www.facebook.com/discussexcel
>
> FORUM RULES
>
> 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) Jobs posting is not allowed.
> 6) Sharing copyrighted material and their links is not allowed.
>
> NOTE : Don't ever post confidential data in a workbook. Forum owners and
> members are not responsible for any loss.
> ---
> You received this message because you are subscribed to the Google Groups
> "MS EXCEL AND VBA MACROS" group.
> To post to this group, send email to excel-macros@googlegroups.com.
> To unsubscribe from this group, send email to
> excel-macros+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/excel-macros?hl=en.
>
>
>



-- 
With Regards,
Noorain Ansari
http:// 
<http://www.noorainansari.com>noorainansari.com<http://www.noorainansari.com>
http:// 
<http://www.excelvbaclinic.blogspot.com>excelvbaclinic.com<http://www.excelvbaclinic.blogspot.com><http://accesssqclinic.blogspot.in/>

-- 
Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

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) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To post to this group, send email to excel-macros@googlegroups.com.
To unsubscribe from this group, send email to 
excel-macros+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros?hl=en.


Reply via email to