#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Row count

Hi all,

How do I write the code for the following. I need a vba to look up the
value in column "a" on a sheet called "reg". If the cells value is greater
than 1 i need in column "g" to input this code .

=IF(A2 500,"yes","no")

I want this to show the row number it is on instead of "a2" it might be a31
or something

Any help would be great as I have no idea how to do this

Thanks

Greg


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Row count

Just a follow on i need it to do it for all the rows in the worksheet.
Thanks again

greg
"Greg" wrote in message
...
Hi all,

How do I write the code for the following. I need a vba to look up the
value in column "a" on a sheet called "reg". If the cells value is
greater than 1 i need in column "g" to input this code .

=IF(A2 500,"yes","no")

I want this to show the row number it is on instead of "a2" it might be
a31 or something

Any help would be great as I have no idea how to do this

Thanks

Greg



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Row count

Hi Greg,

Try:

'=============
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim rCell As Range

Set WB = Workbooks("YourWorkbook.xls") '<<==== CHANGE
Set SH = WB.Sheets("reg")
Set rng = Intersect(SH.UsedRange, SH.Columns("A"))

For Each rCell In rng.Cells
With rCell
If IsNumeric(.Value) And .Value 1 Then
rCell(1, 7).FormulaR1C1 = _
"=IF(RC[-6] 500,""yes"",""no"")"
End If
End With
Next rCell
End Sub
'<<=============


---
Regards,
Norman



"Greg" wrote in message
...
Just a follow on i need it to do it for all the rows in the worksheet.
Thanks again

greg
"Greg" wrote in message
...
Hi all,

How do I write the code for the following. I need a vba to look up the
value in column "a" on a sheet called "reg". If the cells value is
greater than 1 i need in column "g" to input this code .

=IF(A2 500,"yes","no")

I want this to show the row number it is on instead of "a2" it might be
a31 or something

Any help would be great as I have no idea how to do this

Thanks

Greg





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Row count

Thanks for that Norman

Greg
"Norman Jones" wrote in message
...
Hi Greg,

Try:

'=============
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim rCell As Range

Set WB = Workbooks("YourWorkbook.xls") '<<==== CHANGE
Set SH = WB.Sheets("reg")
Set rng = Intersect(SH.UsedRange, SH.Columns("A"))

For Each rCell In rng.Cells
With rCell
If IsNumeric(.Value) And .Value 1 Then
rCell(1, 7).FormulaR1C1 = _
"=IF(RC[-6] 500,""yes"",""no"")"
End If
End With
Next rCell
End Sub
'<<=============


---
Regards,
Norman



"Greg" wrote in message
...
Just a follow on i need it to do it for all the rows in the worksheet.
Thanks again

greg
"Greg" wrote in message
...
Hi all,

How do I write the code for the following. I need a vba to look up the
value in column "a" on a sheet called "reg". If the cells value is
greater than 1 i need in column "g" to input this code .

=IF(A2 500,"yes","no")

I want this to show the row number it is on instead of "a2" it might be
a31 or something

Any help would be great as I have no idea how to do this

Thanks

Greg







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
Count Employee Work Time - Don't Count Duplicates J Excel Worksheet Functions 3 May 1st 07 10:47 PM
Count Employee Work Time - Don't Double-count Overlapping Apts. J Excel Worksheet Functions 0 April 27th 07 05:52 AM
Excel 2000, count, sort a list & count totals? sunslight Excel Worksheet Functions 1 April 9th 07 05:46 PM
How do i count numbers and letters to find a total count of all Linda Excel Worksheet Functions 4 November 10th 05 04:51 PM
Count Intervals of Filtered TEXT values in Column and Return Count across a Row Sam via OfficeKB.com Excel Worksheet Functions 9 July 31st 05 03:37 AM


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

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

About Us

"It's about Microsoft Excel"