Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Searching for values in a given range and then prepending a formula

Hello

I'd trying to write some code to do the following. Any help much
appreciated.

Find the last row in the worksheet with cells that are not empty, then
define a selection between that row and row 4.
Within that selection, iteratively find cells that contain a value
(number only). For each cell that does, take that number and write
into a simple formula in that cell: '=[found value]/$H$3'.

Thanks
Ben

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Searching for values in a given range and then prepending a formul

for a specific column I assume. For illustration, for the pseudo code below,
I will use column B.

Sub ABC()
Dim rng as Range, rng1 as Range, cell as Range
set rng = Range(cells(4,2),cells(rows.count,2))
on error resume next
set rng1 = rng.specialcells(xlconstants,xlnumbers)
On error goto 0
if not rng1 is nothing then
for each cell in rng1
cell.formula = "=" & cell.Value & "/$H$3"
next
End if
End sub

--
Regards,
Tom Ogilvy


"Ben Burns" wrote:

Hello

I'd trying to write some code to do the following. Any help much
appreciated.

Find the last row in the worksheet with cells that are not empty, then
define a selection between that row and row 4.
Within that selection, iteratively find cells that contain a value
(number only). For each cell that does, take that number and write
into a simple formula in that cell: '=[found value]/$H$3'.

Thanks
Ben


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Searching for values in a given range and then prepending a formul

On 18 Jun, 13:38, Tom Ogilvy
wrote:
for a specific column I assume. For illustration, for the pseudo code below,
I will use column B.

Sub ABC()
Dim rng as Range, rng1 as Range, cell as Range
set rng = Range(cells(4,2),cells(rows.count,2))
on error resume next
set rng1 = rng.specialcells(xlconstants,xlnumbers)
On error goto 0
if not rng1 is nothing then
for each cell in rng1
cell.formula = "=" & cell.Value & "/$H$3"
next
End if
End sub

--
Regards,
Tom Ogilvy

"Ben Burns" wrote:
Hello


I'd trying to write some code to do the following. Any help much
appreciated.


Find the last row in the worksheet with cells that are not empty, then
define a selection between that row and row 4.
Within that selection, iteratively find cells that contain a value
(number only). For each cell that does, take that number and write
into a simple formula in that cell: '=[found value]/$H$3'.


Thanks
Ben


Brilliant. Thank you Tom

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
Searching a date range to output values according to a constant. Geebz Excel Discussion (Misc queries) 2 December 1st 06 09:34 AM
Searching a date range to output values according to a constant. daddylonglegs Excel Discussion (Misc queries) 0 November 30th 06 08:23 PM
Formula for Searching & matching two values in excel Chris Excel Discussion (Misc queries) 1 January 7th 05 04:34 PM
Searching a range and copying values into a new range.... **Please help** :( Lancia Excel Programming 1 September 29th 04 01:08 PM
Searching for Data Values in a Column - Formula Only Mark D'Agosta Excel Programming 4 September 29th 03 03:48 AM


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