davidepstein22
New Member
- Joined
- Aug 27, 2012
- Messages
- 27
Hello,
I have an Excel table that I update with new information each month. When new data is added (new rows), using VBA I enter a vlookup into the new rows and the correct data is retrieved. However, when I select the new rows and try to overwrite the vlookup formulas with values (Paste Special Values), the amounts all change to zero (0). Interestingly, if I walk-through the code in debug it works correctly. I tried adding doevents, but that is not working. I suspect it has to do with the fact that I working within a table, but I don't know why this is an issue. Any help would be greatly appreciated. Thank you!
This code to add the vlookup works correctly.
ActiveSheet.Cells(tblSalesLastRow + 1, tblSalesUnitsSoldcolumn).Select
Selection.Formula = "=IFNA(VLOOKUP(Sales[@[Model '#]],'Last Months Sales'!$h$2:$i$1001,2,FALSE),0)"
Selection.Copy
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
This code does NOT work and I have tried many variations.
ActiveSheet.Cells(tblSalesLastRow + 1, tblSalesUnitsSoldcolumn).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Thanks,
Dave
I have an Excel table that I update with new information each month. When new data is added (new rows), using VBA I enter a vlookup into the new rows and the correct data is retrieved. However, when I select the new rows and try to overwrite the vlookup formulas with values (Paste Special Values), the amounts all change to zero (0). Interestingly, if I walk-through the code in debug it works correctly. I tried adding doevents, but that is not working. I suspect it has to do with the fact that I working within a table, but I don't know why this is an issue. Any help would be greatly appreciated. Thank you!
This code to add the vlookup works correctly.
ActiveSheet.Cells(tblSalesLastRow + 1, tblSalesUnitsSoldcolumn).Select
Selection.Formula = "=IFNA(VLOOKUP(Sales[@[Model '#]],'Last Months Sales'!$h$2:$i$1001,2,FALSE),0)"
Selection.Copy
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
This code does NOT work and I have tried many variations.
ActiveSheet.Cells(tblSalesLastRow + 1, tblSalesUnitsSoldcolumn).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Thanks,
Dave