+ Reply to Thread
Results 1 to 2 of 2

make me less ugly please

  1. #1
    Registered User
    Join Date
    06-13-2004
    Posts
    8

    Red face make me less ugly please

    Hey all

    I have written this code to counta() a range of cells, however it is very ugly can someone please provide suggestions on how this can be better achieved?

    Basically the problem is to code a dynamic range into a formula.

    Please Login or Register  to view this content.
    Thank you

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    dabith

    try this code

    Public Sub count_trans()

    Dim LastRow As Long
    Dim FirstRow As Integer

    ' Determine what the first row with data is
    FirstRow = Cells.Find(what:="As of Date", After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, searchorder:=xlByRows, searchdirection:=xlNext, _
    MatchCase:=False).Row + 1

    ' Determine what the last row with data is
    LastRow = ActiveSheet.Cells.Find(what:="*", searchorder:=xlByRows, _
    searchdirection:=xlPrevious).Row

    Cells(LastRow + 2, ActiveCell.Column).Value = "=counta(B" & LastRow & ":B" & FirstRow & ")"

    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1