how to remove values once cells been updated

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,227
Office Version
  1. 2010
Platform
  1. Windows
hi I have the code below where I have added a vlookup, but once the cells are updated I want to remove the vlookup, I have tried '.value=.value' but that didn't work can you help please?
Code:
Private Sub CommandButton1_Click()
 Dim copySheet As Worksheet
  Dim pasteSheet As Worksheet
  Set copySheet = Worksheets("Jun")
  Set pasteSheet = Worksheets("Jun")
  
      Set r = Range("AP2", Range("AP" & Rows.Count).End(xlUp))
    Range("A2").Resize(r.Rows.Count).Value = r.Value
  
  Lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
  On Error Resume Next
  Range("AJ2:AJ" & Lastrow).SpecialCells(xlBlanks).Value = Range("AJ2").Value
  On Error GoTo 0
Range("AJ2", Range("AJ2").End(xlDown)).Copy Range("I2")
Range("AB2", Range("AB2").End(xlDown)).Copy Range("E2")
Range("AD2", Range("AD2").End(xlDown)).Copy Range("F2")
Range("AO2", Range("AO2").End(xlDown)).Copy Range("G2")
Range("AG2", Range("AG2").End(xlDown)).Copy Range("H2")
Range("AS2", Range("AS2").End(xlDown)).Copy Range("M2")
Range("C2:C" & Lastrow).Formula = "=VLOOKUP(A2,Apr!A:D,3,FALSE)"
Range("B2:B" & Lastrow).Formula = "=IF(A2=A1,0,1)"
Range("D2:D" & Lastrow).Formula = "=VLOOKUP(A2,Apr!A:E,4,FALSE)"
Range("J2:J" & Lastrow).Formula = "=VLOOKUP(A2,Apr!A:K,10,FALSE)"
Range("K2:K" & Lastrow).Formula = "=VLOOKUP(A2,Apr!A:L,11,FALSE)"
Range("L2:L" & Lastrow).Formula = "=VLOOKUP(A2,Apr!A:M,12,FALSE)"
Range("N2:N" & Lastrow).Formula = "=VLOOKUP(A2,Apr!A:O,14,FALSE)"
End Sub
 
given the fact that setting a breakpoint and then run the code does "nothing" - as you said yesterday - I doubt that the code is running anyway
try stepping through the code using F8 . . and see what happens
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
hi I can only see it working up to this line when pressing F8. hope you advise.
Code:
Range("N2:N" & Lastrow).Formula = "=VLOOKUP(A2,Apr!A:O,14,FALSE)"
 
Upvote 0
I don't know what you mean sorry, I put the vArr in as I was advised to but don't know what it means
 
Upvote 0
you should invest some time in reading how to operate the VBA-editor, how to inspect local variables and so on (no tips from me there, i'm afraid )
because without your info I can't help you
 
Upvote 0
what info do you need? what do you mean you mean by the values of Varr?
 
Upvote 0
val1val2val3sum
87045=SUM(A2:C2)
99066=SUM(A3:C3)
8146100=SUM(A4:C4)
28133=SUM(A5:C5)
677319=SUM(A6:C6)
986947=SUM(A7:C7)
154778=SUM(A8:C8)
57177=SUM(A9:C9)
244498=SUM(A10:C10)

<tbody>
</tbody>

Code:
Sub SetVals()
    Dim MyRange As Range
    Dim vArr()
    Set MyRange = [D2:D10]
    vArr = MyRange.Value
    MyRange = vArr
End Sub
OK . . . let's try this.
Make a new simple xlsm with the data above (just random numbers with sums in Col D), place the code and run it . . .
What happens?
 
Upvote 0
hi that works it clears the =SUM bit from the cell :)
how do I put that into my code? please
 
Upvote 0
well . . the point is: it is the same code, this is just proof of principle
that's why it's important to know the values stored in the vArr array by opening the local variable-window from the view-menu
 
Upvote 0
oww, what do you mean by the values stored in vArr? I don't have a variable window
 
Upvote 0

Forum statistics

Threads
1,214,952
Messages
6,122,454
Members
449,083
Latest member
Ava19

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