Consulting

Results 1 to 3 of 3

Thread: Hint about VBA functions

  1. #1

    Hint about VBA functions

    Hi everybody,

    Is there any function in VB that represents the following loop

    [vba]
    w = 0
    For k = 1 To ActiveSheet.UsedRange.Columns.Count
    If ActiveSheet.Cells(2, k) = Empty Then
    w = w + 1
    End If
    Next k

    if w < ActiveSheet.UsedRange.Columns.Count then
    MsgBox "Row is not Empty"
    [/vba]

    Thanks in advance

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]Dim Rng As Range, msg As String
    With ActiveSheet
    Set Rng = Intersect(.Rows(2), .UsedRange)
    If Application.CountA(Rng) < Rng.Cells.Count Then
    msg = "Not empty"
    Else
    msg = "Empty"
    End If
    End With
    MsgBox msg
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Thanks for help

Posting Permissions

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