Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Code Help Needed

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Code Help Needed

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

"NEWER USER" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Code Help Needed


"NEWER USER" skrev i en meddelelse
...
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


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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Code Help Needed

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
--
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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Code Help Needed

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

"Mike H" wrote:

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

"NEWER USER" wrote:

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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Code Help Needed

Jim,

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

"Jim Cone" wrote:

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
--
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

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
VB code needed Anthony Excel Programming 5 December 11th 07 11:18 AM
Help with code needed Les Stout[_2_] Excel Programming 3 December 5th 06 12:54 PM
Help needed with VBA code Sam Hill Excel Discussion (Misc queries) 1 May 9th 06 02:29 PM
Help Please - last bit of code needed Mark Dullingham Excel Programming 4 May 6th 06 12:33 AM
Code Fix Needed Phil Hageman[_3_] Excel Programming 2 February 28th 04 01:16 AM


All times are GMT +1. The time now is 09:55 AM.

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"