Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Adding a WHERE statement

I recorded a basic macro and want to add a WHERE statement in the body and
need some help. I recorded

Range("B2").Select
ActiveCell.FormulaR1C1 = "1"
Range("B2").Select
Selection.Copy
Range("B2:B65536").Select
Application.CutCopyMode = False
Selection.FillDown
Range("A2").Select

I want to fill Column B entirely WHERE any value LESS THAN 2 OR NULL. Any
Help appreciated as to where and How to add statement.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Adding a WHERE statement

Never have come across a Where statement. You might be able to use an If
statement or a While statement.

exmpl: For Each cell In Range("B2:B500")
If cell < 2 Or cell = "" Then
'Do Something or Not
End If
Next

or exmpl2: While Range("B2:B500") < 2 Or Range("B2:B500") = ""
'Do Something or Not
Wend

If you would explain what you want to accomplish, somebody will probably be
able to help you.

"NEWER USER" wrote:

I recorded a basic macro and want to add a WHERE statement in the body and
need some help. I recorded

Range("B2").Select
ActiveCell.FormulaR1C1 = "1"
Range("B2").Select
Selection.Copy
Range("B2:B65536").Select
Application.CutCopyMode = False
Selection.FillDown
Range("A2").Select

I want to fill Column B entirely WHERE any value LESS THAN 2 OR NULL. Any
Help appreciated as to where and How to add statement.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Adding a WHERE statement

I have an Excel table with data in Column A and may or may not have data in
Column B. I f no data is present in Cloumn B, I want to fill the entire
Column B with a value of "1". I don't know how many rows of data exist as it
varies, so I was filling the whole column. I link this table to an Access
database and perform update querries on the database. I suppose Excel uses
the WHILE syntax where Access uses WHERE. My recorded macro places a value of
"1" in EVERY cell instead of just the Null cells.

"JLGWhiz" wrote:

Never have come across a Where statement. You might be able to use an If
statement or a While statement.

exmpl: For Each cell In Range("B2:B500")
If cell < 2 Or cell = "" Then
'Do Something or Not
End If
Next

or exmpl2: While Range("B2:B500") < 2 Or Range("B2:B500") = ""
'Do Something or Not
Wend

If you would explain what you want to accomplish, somebody will probably be
able to help you.

"NEWER USER" wrote:

I recorded a basic macro and want to add a WHERE statement in the body and
need some help. I recorded

Range("B2").Select
ActiveCell.FormulaR1C1 = "1"
Range("B2").Select
Selection.Copy
Range("B2:B65536").Select
Application.CutCopyMode = False
Selection.FillDown
Range("A2").Select

I want to fill Column B entirely WHERE any value LESS THAN 2 OR NULL. Any
Help appreciated as to where and How to add statement.

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
Adding dates in a IF Statement Inchman Excel Discussion (Misc queries) 2 February 15th 12 11:34 PM
adding if statement results Robb27 Excel Worksheet Functions 3 November 20th 04 05:27 AM
Adding a 3rd IF statement ?? yh73090[_5_] Excel Programming 3 October 17th 04 05:57 PM
Adding a 3rd IF statement ?? yh73090[_6_] Excel Programming 0 October 17th 04 04:50 AM
Adding SQL Select Statement Pepe[_2_] Excel Programming 1 January 29th 04 02:19 AM


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