Range gets pasted as a Date

dgroman

New Member
Joined
Jan 25, 2011
Messages
8
So I'm working with VBA to copy and past pivot talbes into a new worksheet. I have several different pivot tables that are being pasted into the new worksheet, one of which has some ranges 0-4, 5-9,10-14 and 15+. When it pastes 5-9 and 10-14, it keeps coming up as May 9 and October 14, how do I fix this? I've reformatted the cells each time but it still either comes up with that date or the code for that date but not the range. Yet the pivot table has the proper ranges with no problems. Please help....:(
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Welcome to the board.

Try formatting the destination cells as text BEFORE pasting the new value..
 
Upvote 0
You could try formatting the target cells as 'text' before pasting the data to them. I think this ought to work.

HTH
 
Upvote 0
See thats what I've been trying to do but it just doesn't fix the problem its really annoying:mad:. I've never had this problem before, is there a way to write it into the code so that it exludes information in date form?
 
Upvote 0
What code are you currently using for this?
 
Upvote 0
Code:
Call insert_exhibits("A25:O33", "N2:AB10", "P&L-1", "Slide 3 ")
[code]
 
 
Thats the last line of the code where it takes the pivot table from my first worksheet and pastes it into the other worksheet.
 
Upvote 0
Where's the rest of the code?

I think there just might be a sub called 'insert_exhibits' floating about somewhere.:)

PS Are you trying to prepare Excel data for PowerPoint slides?
 
Upvote 0
Code:
Sub insert_exhibits(source_range As String, output_range As String, source_worksheet As String, output_worksheet As String)
'Set xl = CreateObject("Excel.Application")
Source = ThisWorkbook.Name
file_path = ThisWorkbook.Path
Output_File = "P&L Exhibits - In Progress.xls"
'Workbooks.Open Filename:=Output_File
Visible = True
Workbooks(Output_File).Sheets(output_worksheet).Range(output_range) = _
Workbooks(Source).Sheets(source_worksheet).Range(source_range).Value
End Sub
[code]
 
 
Sorry thats the code that has to deal with the pasting code I sent you before.
 
Upvote 0
ok, it's not actually copy/pasting...it's doing A=B

Try Changing this

Workbooks(Output_File).Sheets(output_worksheet).Range(output_range) = _
Workbooks(Source).Sheets(source_worksheet).Range(source_range).Value

to
Code:
With Workbooks(Output_File).Sheets(output_worksheet).Range(output_range)
    .NumberFormat = "@"
    .Value = Workbooks(Source).Sheets(source_worksheet).Range(source_range).Text
End With
 
Upvote 0

Forum statistics

Threads
1,215,003
Messages
6,122,655
Members
449,091
Latest member
peppernaut

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