VBA If_And Worksheet 1 cell A1 = "abc" & b1 = "def" then C1 = Worksheet 2 cell A2

Lynsvyr

New Member
Joined
May 11, 2022
Messages
3
Office Version
  1. 2010
Platform
  1. Windows
I am looking at having a VBA run with 2 conditions to autofill or pull data from another worksheet in the excel file. I have not finished adding all the locations, but i have added 2 different ones to test out on.

Currently on my Shift Notes Tab, I have a formula in the cell ranges of C9:F12 for a specific site (B7), however I would love it if I can create a system where it would pull the data from a set range instead that way if I select a different site (B7) then it would auto-fill the cell with the cell either a code or from a cell range in a different tab (Break Times).

For example, where currently it shows ABQ1 in Range B7 and Night 10 Hour in Range B8, then Range C9 would equal Worksheet Break Time Range E3.

This is my current VBA Module ( I would extend this to all my sites once I can confirm it works, I'd have at least 20 different sites):
Sub If_And()

Worksheets("Shift Notes").Select

If Range("B7") = "ABQ1" And Range("B8") = "Night 10 Hour" Then
Range("C9") = Worksheets("Break Times")("E3")

End Sub



1652925373787.png
1652925504590.png
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,216,075
Messages
6,128,662
Members
449,462
Latest member
Chislobog

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