Bambiontoast
New Member
- Joined
- Mar 15, 2018
- Messages
- 2
I am new to VBA, and tried to find something on google that would teach me how to change a value in my sheet. I found this code:
Now, this is exactly what I'm looking for - BUT - I need the "A1" to not be a static cell address, but take the cell address from a value found in a cell.
For example, say A1 contains the below formula:
This formula returns the address of a cell, and my goal is to increase the value of the cell found at this address by 1 by pressing a button.
How do I tell VBA to either:
- Use the value of a specific cell and convert that into a Range object (i.e. above formula returns value 'C10', I therefore want to increase value in cell C10 by 1)
- Perform a Vlookup or Index type function itself to find the correct cell to change, based on lookup value G6
I would prefer the former option since I want to keep as much to formulas as possible, but if there is a far easier way to do all of this in code (i.e. skipping the =Cell("address") function) then that would also be fine. If the best way to achieve this is through code alone, could you please explain the critical parts of the code so I can understand how to change or adapt it as required.
Thanks a lot!
,0),2))
Code:
[COLOR=#252C2F][FONT=Helvetica]Range("A1").Value = 1+Range("A1").Value[/FONT][/COLOR]
Now, this is exactly what I'm looking for - BUT - I need the "A1" to not be a static cell address, but take the cell address from a value found in a cell.
For example, say A1 contains the below formula:
Code:
=CELL("address",INDEX(B5:D11,MATCH(G6,B5:B11,0),2))
This formula returns the address of a cell, and my goal is to increase the value of the cell found at this address by 1 by pressing a button.
How do I tell VBA to either:
- Use the value of a specific cell and convert that into a Range object (i.e. above formula returns value 'C10', I therefore want to increase value in cell C10 by 1)
- Perform a Vlookup or Index type function itself to find the correct cell to change, based on lookup value G6
I would prefer the former option since I want to keep as much to formulas as possible, but if there is a far easier way to do all of this in code (i.e. skipping the =Cell("address") function) then that would also be fine. If the best way to achieve this is through code alone, could you please explain the critical parts of the code so I can understand how to change or adapt it as required.
Thanks a lot!
,0),2))