Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2008

Tip: Looking for answers? Try searching our database.

Code Help Needed

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
NEWER USER - 25 Jan 2008 20:46 GMT
I need to fill a Column (B) with a value of "1" in every cell that is null up
to the last row having a value in Column (A).  There are no empty cells in
column A up to the last row with data in the spreadsheet.  I can not
accomplish through a recorded macro.  Can anybody help me with some coding to
accomplish this task?  Thank you
Mike H - 25 Jan 2008 20:58 GMT
We may be at cross purposes over the definition of Null but try this

Sub Sonic()
Set myrange = Range("B1:B" & Cells(Rows.Count, "A").End(xlUp).Row)
For Each c In myrange
   If IsNull(c) Then c.Value = 1
Next
End Sub

Mike

> I need to fill a Column (B) with a value of "1" in every cell that is null up
> to the last row having a value in Column (A).  There are no empty cells in
> column A up to the last row with data in the spreadsheet.  I can not
> accomplish through a recorded macro.  Can anybody help me with some coding to
> accomplish this task?  Thank you
NEWER USER - 25 Jan 2008 21:23 GMT
Problem with IsNull.  I replaced with If (c) =2 Then c.Value = 1 and it
worked fine.  So, I want to replace EMPTY cells with 1.  What do I use or
change IsNull to?  I( feel I am almost there. Thanks

> We may be at cross purposes over the definition of Null but try this
>
[quoted text clipped - 12 lines]
> > accomplish through a recorded macro.  Can anybody help me with some coding to
> > accomplish this task?  Thank you
Per Jessen - 25 Jan 2008 21:01 GMT
>I need to fill a Column (B) with a value of "1" in every cell that is null
>up
[quoted text clipped - 3 lines]
> to
> accomplish this task?  Thank you

Hi

Sub FillColB()
Dim tRange As Range
Dim c
Set tRange = Range("A1", Range("A1").End(xlDown))

For Each c In tRange
   If c.Value <> "" Then c.Offset(0, 1).Value = 1
Next
End Sub

regards,

Per
Jim Cone - 25 Jan 2008 21:09 GMT
Sub FillIn()
Dim rng As Range
Dim rBlanks As Range

Set rng = Cells(Rows.Count, 1).End(xlUp).Offset(0, 1)
Set rBlanks = Range("B1", rng).SpecialCells(xlCellTypeBlanks)
rBlanks.Value = 1
End Sub
Signature

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)

"NEWER USER"
wrote in message
I need to fill a Column (B) with a value of "1" in every cell that is null up
to the last row having a value in Column (A).  There are no empty cells in
column A up to the last row with data in the spreadsheet.  I can not
accomplish through a recorded macro.  Can anybody help me with some coding to
accomplish this task?  Thank you

NEWER USER - 25 Jan 2008 21:44 GMT
Jim,

Thanks for the help.  You nailed it.  Have a GREAT weekend.  Many Thanks

> Sub FillIn()
> Dim rng As Range
[quoted text clipped - 4 lines]
> rBlanks.Value = 1
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.