Noah Rainey
Noah Rainey

Reputation: 73

Adding value to range on different sheet from range + subtraction

I have users inputting a specific name and value (from 65-90) in a range E12, E13 respectively. I'm trying to get the name, from E12 to a range corresponding to the value entered in E13 minus 51, so if the user enters 65 in E13, Sheet2 will reflect the name from E12 on the range of B14. I was assuming the following code would suffice, but it doesn't seem to.

Sub Worksheet_Change(ByVal Target As Range)
    Sheets("Sheet2").Range("B" & Sheets("Sheet1").Range("E13").Value - 51).Value = Sheets("Sheet1").Range("E12").Value
End Sub

This snippet is intended to be copied and used 20 times on a sheet for potentially 20 entries so the ranges from sheet1 will change.

I may be going about it in a completely wrong fashion so any assistance would be appreciated.

Upvotes: 0

Views: 954

Answers (1)

leventcinel
leventcinel

Reputation: 358

Try this, I'm not sure if it works...
Define a variable to

Sheets("Sheet1").Range("E13").Value

and then use

variable - 51

in your code. Hope it solves your problem.

Upvotes: 1

Related Questions