Paste values not working in a table

davidepstein22

New Member
Joined
Aug 27, 2012
Messages
27
Hi all,

I don't know if I found a MSFT bug, but let me explain my dilemma and I would appreciate your comments/suggestion

1. My spreadsheet reads about 25-sales files using Power Query and places the data in a new sheet. This works correctly
2. I summarize #1 using the unique function to calculate the total units sold by model number. This works correctly.
3. My VBA reads the new month's data and enters the data into my Sales table (a formal Excel table). This works correctly.
4. The VBA code attempts to convert the formulas into values in the Units Sold column for the new rows (cells), but it always returns "0" (over writing the actual values). I expected a simple copy | paste values would work, but it does not. I even tried copying the values to a new workbook and then pasting them back to the desired sheet, but it did not work, nor many other approaches.

I am convinced there is a bug or table behavior is causing to occur, but I can't identify the cause. I would appreciate your help.


Thanks,
Dave
 
I am afraid I don't do calls or personal emails on the forum.
If you can't upload a sample file only showing the issue then I afraid that can't help further.

I am out for the next few hours anyway (being dragged shopping, which will need a few coffees along the way)
 
Upvote 0

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hi Mark, et all,

This is why I do not think it is a coding error... The code below writes to column F, which is my Excel table and returns a zero value to all of the cells/rows. When I write to column M, which outside of my table and returns the correct value (mostly non-zero numbers). Hence, I return to my original thought, that this has something to do with writing into a table. Any thoughts?

Set rng = Sheets("sales").ListObjects("Sales").ListColumns("Units Sold").DataBodyRange
UnitsSold = rng
Sheets("sales").Range("m2:m283") = UnitsSold()
Sheets("sales").Range("f2:f283") = UnitsSold()
 
Upvote 0
The code below worked perfectly well putting values in a table for me (column M outside the table and column F inside the table)

VBA Code:
Sub test4()
    Dim Rng As Variant, UnitsSold As Variant
    Set Rng = Sheets("sales").ListObjects("Sales").ListColumns("Units Sold").DataBodyRange
    UnitsSold = Rng.Value
    Sheets("sales").Range("m2:m283") = UnitsSold
    Sheets("sales").Range("f2:f283") = UnitsSold
End Sub

and the same with entering a formula in a table and converting to values

VBA Code:
Sub test4b()
   Sheets("sales").Range("f2").FormulaR1C1 = "=[@[Units Sold]]"
    With Sheets("sales").Range("f2:f283")
        .Value = .Value
    End With
End Sub
 
Last edited:
Upvote 0
The code below worked perfectly well putting values in a table for me (column M outside the table and column F inside the table)

VBA Code:
Sub test4()
    Dim Rng As Variant, UnitsSold As Variant
    Set Rng = Sheets("sales").ListObjects("Sales").ListColumns("Units Sold").DataBodyRange
    UnitsSold = Rng.Value
    Sheets("sales").Range("m2:m283") = UnitsSold
    Sheets("sales").Range("f2:f283") = UnitsSold
End Sub

and the same with entering a formula in a table and converting to values

VBA Code:
Sub test4b()
   Sheets("sales").Range("f2").FormulaR1C1 = "=[@[Units Sold]]"
    With Sheets("sales").Range("f2:f283")
        .Value = .Value
    End With
End Sub
 
Upvote 0
Hi all,

Mark, Your code works perfectly fine when I run it in debug mode, but not when I run the VBA code in a normal execution mode. I am sure it is not your code, as I have tried about 10 different methods to accomplish the same task and they all work in debug mode, but not when I run the code normally.

I may try recreating the table from scratch - hoping for a miracle. I will let you know what happens. THANK YOU.
 
Upvote 0
I ran both codes from a button on the same sheet when testing
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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