![]() |
Referencing Cells in Macros
Hi,
I have a list of numbers which I am searching through, Once I find the one I'm looking for,( eg. in Cell A8), I need to return the value in the adjacent cell,( B8), increment the value in the cell by 1 and return the new value to the cell B8. I was using the lookup function to find the number I was seeking, however, once I get the relevant value and increment it I can't sent it back to the cell it originally came from... Anybody got any ideas??? Any help would be appreciated |
Referencing Cells in Macros
Try something like this:
Sub test1() Dim anyvalue As Double Dim anyrange As Range Set anyrange = Range("A5:A500") anyvalue = 3 Increment anyvalue, anyrange End Sub Sub Increment(What As Double, Where As Range) Dim rFind As Range Set rFind = Where.Find(What) If Not rFind Is Nothing Then rFind.Offset(0, 1).Value = _ rFind.Offset(0, 1).Value + 1 End If End Sub Patrick Molloy Microsoft Excel MVP -----Original Message----- Hi, I have a list of numbers which I am searching through, Once I find the one I'm looking for,( eg. in Cell A8), I need to return the value in the adjacent cell,( B8), increment the value in the cell by 1 and return the new value to the cell B8. I was using the lookup function to find the number I was seeking, however, once I get the relevant value and increment it I can't sent it back to the cell it originally came from... Anybody got any ideas??? Any help would be appreciated . |
Referencing Cells in Macros
Formulas can't send values to other cells.
You would need a macro to do this. -- Regards, Tom Ogilvy "Gerry" wrote in message ... Hi, I have a list of numbers which I am searching through, Once I find the one I'm looking for,( eg. in Cell A8), I need to return the value in the adjacent cell,( B8), increment the value in the cell by 1 and return the new value to the cell B8. I was using the lookup function to find the number I was seeking, however, once I get the relevant value and increment it I can't sent it back to the cell it originally came from... Anybody got any ideas??? Any help would be appreciated |
All times are GMT +1. The time now is 02:11 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com