Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default Coding help needed

I can't get the portion of below code **"test and provide for blank cells"
**
to work properly. Can someone assist?
TIA,


Sub demo()

Dim rSource As Range ' the area to be "viewed"
Dim rCell As Range ' for looping through the view
Dim msg As String ' body of the message
Dim title As String ' title of the message

Set rSource = Range("D5:H15")

For Each rCell In rSource

' initialise message variables
title = "row: %R"
msg = "Address: %A " & Chr(10) & "Value: %V"

' populate message variables
title = Replace(title, "%R", rCell.Row)
msg = Replace(msg, "%A", rCell.Address)
msg = Replace(msg, "%V", rCell.Value)

' test and provide for blank cells
If rCell.Value = "" Then
msg = Replace(msg, rCell.Value, "The Cell is Blank")
End If

' show message & test for user cancel
If MsgBox(msg, vbOKCancel, title) = _
vbCancel Then
Exit For
End If
Next
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Coding help needed


"JMay" wrote in message
news:5SuLb.70602$hf1.69573@lakeread06...
I can't get the portion of below code **"test and provide for blank cells"
**
to work properly. Can someone assist?
TIA,


' test and provide for blank cells
If rCell.Value = "" Then
msg = Replace(msg, rCell.Value, "The Cell is Blank")
End If


You are trying to replace nothing with something. Nothing is nothing, so it
won't be found, therefore you cannot replace it. Just use this code

' test and provide for blank cells
If rCell.Value = "" Then
msg = msg & "The Cell is Blank"
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default Coding help needed

Thanks Bob for the explanation - it has added to my
<<sorely-neededunderstanding of programming (which is fairly new to me).
JMay

"Bob Phillips" wrote in message
...

"JMay" wrote in message
news:5SuLb.70602$hf1.69573@lakeread06...
I can't get the portion of below code **"test and provide for blank

cells"
**
to work properly. Can someone assist?
TIA,


' test and provide for blank cells
If rCell.Value = "" Then
msg = Replace(msg, rCell.Value, "The Cell is Blank")
End If


You are trying to replace nothing with something. Nothing is nothing, so

it
won't be found, therefore you cannot replace it. Just use this code

' test and provide for blank cells
If rCell.Value = "" Then
msg = msg & "The Cell is Blank"
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)




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
sum by coding [email protected] New Users to Excel 1 February 27th 08 01:12 PM
How to fix the coding? Eric Excel Worksheet Functions 0 February 26th 08 03:38 AM
How to fix the coding? Eric Excel Worksheet Functions 4 June 20th 07 02:42 PM
VBA coding needed badly Seeking help New Users to Excel 9 July 7th 06 06:58 AM
Help needed coding a macro to adjust the source of information each time it is run lbauckman Excel Programming 1 November 4th 03 08:13 AM


All times are GMT +1. The time now is 07:59 PM.

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

About Us

"It's about Microsoft Excel"