Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 25th, 2013, 06:58 AM
Registered User
 
Join Date: Jul 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need Help to Extract data from required tab as per condition

Hi Everyone,

I have one workbook and that workbook contains total 15 Tabs and i want extract data only from
3 tabs ("Subscription","SIP","Back or Future date")

again from each tab we have different different calculation, below is the steps.

in all tabs row is starts from 7th row

1) workbook will open
2) add new tab and named as "99 Trxns"
3) next from "Subscription" tab Filter (contains 99) from C-Column and copy only some required column
like (See attached in required header tab) and paste in "99 Trxn" tab at range A1
4)next from "SIP" tab Filter (contains 99) from C-Column and copy only some required column
like (See attached in required header tab) and paste in "99 Trxn" tab at 2nd next empty row
5)next from "Back or Future date" tab Filter (contains 99) from D-Column and copy only some required column
like (See attached in required header tab) and paste in "99 Trxn" tab at 2nd next empty row.

Note: If possible please make VBA Code by using (Lbound,Ubound,select case,array) properties or else in your possible way.

Note: Required Columns Headers I mention in attached File in 1st tab.

I hope my explanation is understandable.

Thanks - Naveed.
 
Old July 30th, 2013, 10:32 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi Naveed

Please post the code you had written/attempted till now and highlight the portion where you are stuck.

This would help others provide quick responses

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old August 1st, 2013, 03:20 AM
Registered User
 
Join Date: Jul 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear Sir

After putting lot of efforts on this finally i prepared myself below is the code which is prepared by me.

Code:
Sub online_trxn()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
mymc = ActiveWorkbook.Name
arr = Array("Subscriptions", "SIP", "Back or Future Dated Trans")
Worksheets.Add
ActiveSheet.Name = "99 Trxn"
Set sh = Sheets("99 Trxn")
With sh
FR = .Range("A" & .Rows.Count).End(xlUp).Row
fc = .Range("A" & .Columns.Count).End(xlToLeft).Column
For i = LBound(arr, 1) To UBound(arr, 1)
    Select Case arr(i)
        Case "Subscriptions", "SIP"
            If Sheets(arr(i)).Range("A8").Value = "" Then
                Sheets(arr(i)).Range("A8").EntireRow.Delete
            End If
            LR = Sheets(arr(i)).Range("A" & Rows.Count).End(xlUp).Row
            vl = Application.WorksheetFunction.CountIf(Sheets(arr(i)).Range("C7:C" & LR), "*99*")
            If vl >= 1 Then
                Sheets(arr(i)).Range("C7").AutoFilter Field:=3, Criteria1:="*99*"
            Select Case arr(i)
                Case "Subscriptions"
                    hdrs = Array("A", "B", "C", "D", "E", "F", "H", "I", "J", "K", "N", "S", "T", "AJ", "AK", "AM", "AN", "AO")
                    For j = LBound(hdrs, 1) To UBound(hdrs, 1)
                        Sheets(arr(i)).Range(hdrs(j) & "7" & ":" & hdrs(j) & LR).Copy sh.Cells(FR, fc)
                        fc = fc + 1
                    Next
                    FR = .Range("A" & .Rows.Count).End(xlUp).Row + 2
                    fc = 1
                Case "SIP"
                    hdrs = Array("A", "B", "C", "D", "E", "F", "H", "U", "V", "W", "Y", "AC", "AD", "AG", "AH", "AJ", "AK", "AL")
                    For k = LBound(hdrs, 1) To UBound(hdrs, 1)
                        Sheets(arr(i)).Range(hdrs(k) & "7" & ":" & hdrs(k) & LR).Copy sh.Cells(FR, fc)
                        fc = fc + 1
                    Next
                    FR = .Range("A" & .Rows.Count).End(xlUp).Row + 2
                    fc = 1
            End Select
            Else
                MsgBox "No 99 Trxn in " & arr(i) & " Tab"
            End If

        Case "Back or Future Dated Trans"
            If Sheets(arr(i)).Range("A8").Value = "" Then
                Sheets(arr(i)).Range("A8").EntireRow.Delete
            End If
            LR = Sheets(arr(i)).Range("A" & Rows.Count).End(xlUp).Row
            vl = Application.WorksheetFunction.CountIf(Sheets(arr(i)).Range("D7:D" & LR), "*99*")
            If vl >= 1 Then
                    Sheets(arr(i)).Range("D7").AutoFilter Field:=4, Criteria1:="*99*"
                    hdrs = Array("A", "B", "D", "E", "F", "G", "I", "J", "K", "L", "O", "U", "V", "C", "AI", "AK", "AL", "AM")
                    For l = LBound(hdrs, 1) To UBound(hdrs, 1)
                        Sheets(arr(i)).Range(hdrs(l) & "7" & ":" & hdrs(l) & LR).Copy sh.Cells(FR, fc)
                        fc = fc + 1
                    Next
            Else
                MsgBox "No 99 Trxn in " & arr(i) & " Tab"
            End If

    End Select
Next
sh.Columns.AutoFit
MsgBox "Done Extracted !"
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
and one more thins sir can u please showed me how to attached workbook here in this forum.
and how can i mark this thread as solved

Last edited by naveed raza; August 1st, 2013 at 03:23 AM..
 
Old August 24th, 2013, 03:28 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

Glad to know that it worked. All the very best

You can upload the file to boxfiles etc and share the link here.

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Required field validators and tab panels--bug? mkarmali BOOK: ASP.NET 3.5 Website Programming Problem Design Solution 1 February 4th, 2010 02:55 PM
Extract data out from datareader yukijocelyn ASP.NET 2.0 Basics 1 September 21st, 2007 07:27 AM
IIS Semaphore Condition[Urgent Help Required] farhan_iac General .NET 4 August 12th, 2004 10:00 AM
Extract Data From Node ryanpatrick XML 1 February 18th, 2004 10:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.