What I'm trying to do is copy an entire sheet into VBA as values. Instead of a copy/paste function, what I want to do is have the code write each cell value so that the original page copied from is not required to be accessible.
So instead of something like:
Range("D9").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
It would look like this:
Range("D9").Select
ActiveCell.FormulaR1C1 = "What ever cell value"
I would like to copy an entire sheet and save it in VBA as formulas for each cell. As text is fine, no actual formulas will be present in the data I need to copy, if that makes it easier.
Thanks so much.
ANSWER:
In the comments are better solutions than the one I was trying to find. However I have reasons for trying to figure out this code. I'm creating complex macros for excel noobs. I don't want to have to trust them to create the data sheets, or even copy them from other workbooks, that are needed for the macros I will give them.
The code I wrote won't work in many cases, such as if cells contain quotation marks or formulas, but it will work for what I'm going to use it for. A few lines of code will be added before I use it to format the entire sheet as text and trim each cell ahead of time, but here's the basic code:
Sub VBA_Formulas()
Dim r As Range
Set r = Selection
For Each r In Intersect(Selection, ActiveSheet.UsedRange)
r.Value = "Range(" & Chr(34) & r.Address & Chr(34) & ").Value = " & Chr(34) & r.Value & Chr(34)
Next r
End Sub
I will then copy all the cells the code ran on into VBA to create the sheets needed to run the macros I will be passing out. There's more code involved but I'm sharing the code I figured out as a solution to the specific question I asked.
Thank you all for your input, I will probably use some of the array techniques in other codes I write at some point.