Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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.


--
Sandeman
------------------------------------------------------------------------
Sandeman's Profile: http://www.excelforum.com/member.php...o&userid=32440
View this thread: http://www.excelforum.com/showthread...hreadid=528451

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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" wrote in
message ...

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default If range F1:K1 are blank, then L1 is "other"


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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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" wrote in
message ...

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing "returned" values from "0" to "blank" LATATC Excel Worksheet Functions 2 October 20th 05 04:41 PM
use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" Luc[_3_] Excel Programming 2 September 28th 05 08:37 PM
Using "Cells" to write "Range("A:A,H:H").Select" Trip Ives[_2_] Excel Programming 3 June 5th 04 03:13 PM
"over-lay" one range onto another range so that only blank cells are affected Paul Simon[_2_] Excel Programming 2 August 6th 03 11:50 AM


All times are GMT +1. The time now is 07:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"