Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default If then statement

Hi,

I have a piece of code that looks at an Excel spreadsheet, copies the cells
data, and puts it in another Excel sheet.

The first piece of data will always be there. But in some cases, subsequent
fields may be blank. So I want to put in an If statement that says if
subsequent values are blank, just fill them in with the first value. Here is
what I have:

testExpected = .Cells(currentRow, 6).Value
*******
If .Cells.Value is Null then
blah blah
End If
*******
Can someone help me with the code inside the asterisks please.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default If then statement


Can you try to use the word 'Empty' instead of 'Null'?
So...

If .Cells.Value = Empty Then
blah
End If




"Catherine Jackson" schreef in
bericht ...
Hi,

I have a piece of code that looks at an Excel spreadsheet, copies the
cells
data, and puts it in another Excel sheet.

The first piece of data will always be there. But in some cases,
subsequent
fields may be blank. So I want to put in an If statement that says if
subsequent values are blank, just fill them in with the first value. Here
is
what I have:

testExpected = .Cells(currentRow, 6).Value
*******
If .Cells.Value is Null then
blah blah
End If
*******
Can someone help me with the code inside the asterisks please.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default If then statement

I tried this with a worksheet and it identified the empty cells correctly.
This may or may not be what you are looking for. A blank cell can be
identified as an empty string "".

Jeff

Sub JEFF()

Dim ROW As Long
Dim TEMP As String

ROW = 1
Do While ROW < 10
TEMP = ActiveSheet.Cells(ROW, 1).Value
If TEMP = "" Then
Cells(ROW, 2).Value = "BLANK"
Else
Cells(ROW, 2).Value = "NOT BLANK"
End If
ROW = ROW + 1
Loop
End Sub

"Catherine Jackson" wrote:

Hi,

I have a piece of code that looks at an Excel spreadsheet, copies the cells
data, and puts it in another Excel sheet.

The first piece of data will always be there. But in some cases, subsequent
fields may be blank. So I want to put in an If statement that says if
subsequent values are blank, just fill them in with the first value. Here is
what I have:

testExpected = .Cells(currentRow, 6).Value
*******
If .Cells.Value is Null then
blah blah
End If
*******
Can someone help me with the code inside the asterisks please.

  #4   Report Post  
Posted to microsoft.public.excel.programming
jtp jtp is offline
external usenet poster
 
Posts: 1
Default If then statement


If you dont want to use a loop statement you can use,

ActiveSheet.UsedRange.SpecialCells(xlCellTypeBlank s).Value = "First
Value"

Now this will put that first value in all blank cells for the entire
used range of the active sheet. If you need to be more specific to a
column or row, just change the first part.


--
jtp
------------------------------------------------------------------------
jtp's Profile: http://www.excelforum.com/member.php...o&userid=21132
View this thread: http://www.excelforum.com/showthread...hreadid=569543

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
IF statement inside a SUMIF statement.... or alternative method Sungibungi Excel Worksheet Functions 3 December 4th 09 06:22 PM
Reconcile Bank statement & Credit card statement & accounting data Bklynhyc Excel Worksheet Functions 0 October 7th 09 09:07 PM
Embedding an OR statement in an IF statement efficiently Chatnoir11 Excel Discussion (Misc queries) 4 February 2nd 09 08:12 PM
Can an If statement answer an If statement? M.A.Tyler Excel Discussion (Misc queries) 2 June 24th 07 04:14 AM
appending and IF statement to an existing IF statement spence Excel Worksheet Functions 1 February 28th 06 11:00 PM


All times are GMT +1. The time now is 06:15 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"