Wrox Programmer Forums
|
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 April 21st, 2006, 01:53 PM
Authorized User
 
Join Date: Apr 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Codeing help

Here's my code:

Private Sub cboOrgShp_Change()
Dim aRowcount As Integer
Dim expenditures As Range
Dim aOrgShp As String

aOrgShp = cboOrgShp.Value
Range("Expenditures").AutoFilter field:=2, Criteria1:=("aOrgShp")
    With Range("expenditures")
    If .EntireRow.Hidden = False Then
        aRowcount = .Rows.Count
        ActiveWorkbook.Names.Add Name:="OrgShp", _
            RefersTo:="=" & .Parent.Name & "!" & .Resize(aRowcount).Address
        txtSEQ.Value = aRowcount
    End If
    End With
End Sub

I can't seem to get it to work correctly. The range name ("Expenditures") is the range of all the rows with data in them. I need to filter the data range via a combobox named cboOrgShp. When the user selects the OrgShp I want the data filtered in the background. Then I want to count the (visible) rows (not including the headers) and assign the value to another Text Box labeled txtSeq, which will be entered onto the ActiveSheet. Finally, I need to unfilter the data back to original range. Basically, if the user filters by OrgShp, all the rows should be in sequential order with the number of the row in the far left column. When the ActiveSheet is unfiltered, the sequence numbers will invarialbly be out of order, which is fine.

Any help would be greatly appreciated.

The basic codeing for this will also be used (seperately and on a CommandButton) to sort the ActiveSheet by OrgShp and print the results.






Similar Threads
Thread Thread Starter Forum Replies Last Post
required codeing [email protected] ADO.NET 2 July 2nd, 2006 01:22 PM





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