Sami Tissaoui
Sami Tissaoui

Reputation: 21

How to use a cell's content as an input for my code?

I have been looking for a solution to use my excel sheet's cells' content as an input for my code. Let's say I have this code that filters certain values if they are different from those listed in this code:

Sub test()
   Dim r As Range 

   SheetName = "DPM"
   With Sheets(SheetName)
      For Each r In .Range("F2", .Range("F" & Rows.Count).End(xlUp))
         If r <> "A" And r <> "B" And r <> "C" Then r.Offset(, 1).ClearContents   > > > 
      Next r
   End With
   Application.ScreenUpdating = True
End Sub

A, B and C change all the time, so I have to constantly update my code with the new values. I thought about having a separate excel sheet where The user puts his values Example: Column A X Y Z so my code will first update itself with these new values and then execute. Note: I don't want to use a text box to ask the user to input the values, I just want to have a sheet like a "map" from which the code will update itself.

I hope this is clear enough, I appreciate your time and help!

Upvotes: 2

Views: 34

Answers (1)

QHarr
QHarr

Reputation: 84465

I think you may be mean something like

Dim inputSht As Worksheet
Set inputSht = ThisWorkbook.Worksheets("input")
If r.Value <> inputSht.Range("A1").Value And r.Value <> inputSht.Range("B1").Value And r.Value <> inputSht.Range("C1").Value 

Upvotes: 1

Related Questions