EXCEL - Trying to get VBA to recognize an input, and throw in a formula into a different cell

خرید بک لینک

I've been spending about 5 hours straight just trying to figure this out. I've tried to Frankenstein together a couple codes I've found across the web to get it to work, but I'm so lost. What ever I think will work, doesn't, and I don't know why at this point.

So I'm here now haha, and here's what I'm trying to do:

Cell F8 and G8 will both have values entered in them, either one or the other, and both need to call a function depending on where the value was entered - whichever cell that has a value entered into, will put a formula in the other cell.

If F8 = value entered
Then G8 produces this formula =F8*C8/231

If G8 = value entered
Then F8 produces this formula =G8*231/C8

And as mentioned, if I enter something into F8, and it gives me the calculation in G8, then, if I enter a value into G8, and it’ll overwrite what I entered in F8 with a formula.

I have about 20 uneducated variations. I google search each function, and trying to find ones that might work better... But I feel like I'm working myself into an endless loop when I put in the other half of the code in for the other cell... But I can't even get one cell to spit a formula into the other, so I don't know any more. Advice would be nice.

Private Sub Change(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("F8:G8")) Is Nothing Then
    If Intersect(Target, Range("G8")) > 0 Then
        Range("F8").Formula = "=G8*231/C8"
    End If
End If
End Sub

I guess I should probably also ask how you get this code to work while I'm here. I pasted this code in the View Code for the Sheet1. Based on what I've read, my understanding is that there's nothing else I need to do, and it should just work silently in the background for me.

EDIT: I just realized that the second intersect function isn't going to work...

Recent Questions...

ما را در سایت Recent Questions دنبال می‌کنید

برچسب: نویسنده: استخدام کار بازدید: 219 تاريخ: پنجشنبه 13 خرداد 1395 ساعت: 5:23

صفحه بندی