VBA - Conditional Cell Values

Rana Gray

Board Regular
Joined
Jan 26, 2023
Messages
56
Office Version
  1. 365
Platform
  1. Windows
  2. Web
Hello Everyone!
I hope this makes sense... I have a table on [Sheet25], Range F5:F97 & G5:G97

What I want is my host cell ("K8") on [Sheet26] to pull a value (in my case a link) from the aforementioned table based on what value is entered on [Sheet13] ("G11")

example: if [Sheet13] ("G11") = "Smith", then [Sheet26] ("K8") = [Sheet25] ("F5")

I know I can use a nest if statement but I have a giant range which makes for an awful formula I am just super new to VBA and don't know how to code it.

Thanks a Million!!!
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
I'm not sure what your criteria are aside from the "Smith" one, but I think this is a good starting point to get you where you want to go.

VBA Code:
Sub RanaGray()

Dim rngG11 As Range
Dim rngK8 As Range
Dim rngF5 As Range

With ActiveWorkbook

  'Set Ranges For Evaluation
  Set rngG11 = .Sheets(13).Range("G11")
  Set rngK8 = .Sheets(26).Range("K8")
  Set rngF5 = .Sheets(25).Range("F5")

  'Evaluate Values
  If rngG11 = "Smith" Then rngK8 = rngF5

End With

End Sub
 
Upvote 1
Solution
I'm not sure what your criteria are aside from the "Smith" one, but I think this is a good starting point to get you where you want to go.

VBA Code:
Sub RanaGray()

Dim rngG11 As Range
Dim rngK8 As Range
Dim rngF5 As Range

With ActiveWorkbook

  'Set Ranges For Evaluation
  Set rngG11 = .Sheets(13).Range("G11")
  Set rngK8 = .Sheets(26).Range("K8")
  Set rngF5 = .Sheets(25).Range("F5")

  'Evaluate Values
  If rngG11 = "Smith" Then rngK8 = rngF5

End With

End Sub
Thank you so much!! It is definitely the right direction :) I appreciate you taking the time to help!!! I never know how to start my script haha
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top