+ Reply to Thread
Results 1 to 4 of 4

If range F1:K1 are blank, then L1 is "other"

Hybrid View

  1. #1
    Registered User
    Join Date
    03-14-2006
    Posts
    23

    If range F1:K1 are blank, then L1 is "other"

    I would like a macro that looks at row F1:K1 and if the range is blank, then the word "other" appears in L1. The data in columns F:K could range from 50 to several hundred rows down so this needs to be flexible.

    Thanks for your help.

  2. #2
    Norman Jones
    Guest

    Re: If range F1:K1 are blank, then L1 is "other"

    Hi Sandeman,

    Try:

    '=============>>
    Public Sub Tester()
    Dim SH As Worksheet
    Dim rng As Range
    Dim rw As Range

    Set SH = ActiveSheet '<<==== CHANGE
    Set rng = Intersect(SH.UsedRange, Columns("F:K"))

    For Each rw In rng.Rows
    If Application.CountA(rw.Cells) = 0 Then
    Cells(rw.Row, "L").Value = "Other"
    End If
    Next rw

    End Sub
    '<<=============


    ---
    Regards,
    Norman


    "Sandeman" <Sandeman.25ivmn_1143789005.0439@excelforum-nospam.com> wrote in
    message news:Sandeman.25ivmn_1143789005.0439@excelforum-nospam.com...
    >
    > I would like a macro that looks at row F1:K1 and if the range is blank,
    > then the word "other" appears in L1. The data in columns F:K could
    > range from 50 to several hundred rows down so this needs to be
    > flexible.
    >
    > Thanks for your help.
    >
    >
    > --
    > Sandeman
    > ------------------------------------------------------------------------
    > Sandeman's Profile:
    > http://www.excelforum.com/member.php...o&userid=32440
    > View this thread: http://www.excelforum.com/showthread...hreadid=528451
    >




  3. #3
    Registered User
    Join Date
    03-14-2006
    Posts
    23
    Excellent Norman. Thank you very much.

    Spoke too soon. The "other" repeats for the length of the spreadsheet. I'd like it to stop when the data stops. Thanks.
    Last edited by Sandeman; 03-31-2006 at 06:05 AM.

  4. #4
    Norman Jones
    Guest

    Re: If range F1:K1 are blank, then L1 is "other"

    Hi Sandeman,

    Assuming that the last data entry can be determined from column A, try:

    '=============>>
    Public Sub Tester2()
    Dim SH As Worksheet
    Dim rng As Range
    Dim rw As Range
    Dim LRow As Long
    Dim i As Long

    Set SH = ActiveSheet '<<==== CHANGE
    LRow = SH.Cells(Rows.Count, "A").End(xlUp).Row
    Set rng = Range("F1:K" & LRow)

    For Each rw In rng.Rows
    If Application.CountA(rw.Cells) = 0 Then
    Cells(rw.Row, "L").Value = "Other"
    End If
    Next rw
    End Sub
    '<<=============

    ---
    Regards,
    Norman



    "Sandeman" <Sandeman.25j3yn_1143799816.4162@excelforum-nospam.com> wrote in
    message news:Sandeman.25j3yn_1143799816.4162@excelforum-nospam.com...
    >
    > Excellent Norman. Thank you very much.
    >
    > Spoke too soon. The "other" repeats for the length of the spreadsheet.
    > I'd like it to stop when the data stops. Thanks.
    >
    >
    > --
    > Sandeman
    > ------------------------------------------------------------------------
    > Sandeman's Profile:
    > http://www.excelforum.com/member.php...o&userid=32440
    > View this thread: http://www.excelforum.com/showthread...hreadid=528451
    >




+ 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