I am trying to create a workbook that allows me to pull data from a source workbook to create a "snapshot" of various metrics on testing data. I accomplished this with vLookUp.
My goal however; is that I would like to create an update button and field so that I can modify cells on the snap shot and update them on the source worksheet. (all in the same workbook)
I have tried to use an update button with a Marco, but it only updates one cell (not the variable range of cells that could be pulled from the named list using vLookUp.) I have not used VBA or Marcos in Excel in probably 4 years, so I may be missing something simple. I have been doing some refresh training, but haven't been able to figure it out.
I tried to just modify a Macro I recorded:
Range("G8").Select
Selection.Copy`enter code here`
Sheets("Dashboard").Select
Range("K3").Select
ActiveSheet.Paste
WITH
Sub Update_Click()
Dim varRange As Range
varRange = "=VLOOKUP(C5,Dashboard!A3:W57,11,FALSE)"
Range("G8").Select
Selection.Copy
Sheets("Dashboard").Select
Range("varRange").Select
ActiveSheet.Paste
End Sub
Another alternative would be to create a new column that could identify the column and row of source cell that vLookUp is referencing.(not the named list cell, I need the cell that is being referenced in the table array of vLookUp) Then I should be able to use that reference cell with the original macro (I think)
I have tried using =CELL("col",VLOOKUP(C5,Dashboard!A3:W57,11,FALSE)) but it gives an error.
MATCH
funciton. It will return row / column of matched data in range. – Scott HoltzmanDim varRange as Range
makes no sense withvarRange = "=VLOOKUP(C5,Dashboard!A3:W57,11,FALSE)"
. You cannot use a Range object in this way, – Scott HoltzmanSet varRange = Sheets("Dashboard").Range("W" & Application.Match(ActiveSheet.Range("C5"),Sheets("Dashboard").Range("A3:A57"),0))
Then the rest in one lineActiveSheet.Range("G8").Copy varRange
. You probably will want to put a check in that the value exists if you are not using data validation on C5. – Scott CranerSet varRange = Sheets("Dashboard").Range("W" & Application.Match(ActiveSheet.Range("C5"),Sheets("Dashboard").Range("A:A"),0))
– Scott Craner