kimberwarden
New Member
- Joined
- Feb 24, 2014
- Messages
- 3
I know there have been lots of questions about this, but I can't seem to apply any of them to my situation and make it work. I want to copy a selection of cells from one workbook to another on a regular basis, the latter of which is a csv file. I use a script to delete the contents of the csv file before pasting in the new values. One of the columns is for user-selected passwords, and sometimes users use a string that looks like a date as their password. Even though the originating file correctly displays the text as "august10" the csv file formats it as 10-Aug even though I'm attempting to paste values and number formatting into a cell that's already formatted as text. Somehow, the cell ends up formatted as Custom and I have no idea why. I've tried everything I can think of and don't know what I'm doing wrong. Here's the script I'm using:
<code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit;">Workbooks.Open Filename:= _ "CSVfile.csv" _ , Origin:=xlWindows Cells.Select Selection.ClearContents Windows("OriginalFile.xls").Activate Sheets("Manipulate").Select Range("Extract").Select Selection.Copy Windows("CSVFile.csv").Activate Range("A1").Select Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Cells.Select Cells.EntireColumn.AutoFit Selection.NumberFormat = "@" Application.CutCopyMode = False</code></pre>
<code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit;">Workbooks.Open Filename:= _ "CSVfile.csv" _ , Origin:=xlWindows Cells.Select Selection.ClearContents Windows("OriginalFile.xls").Activate Sheets("Manipulate").Select Range("Extract").Select Selection.Copy Windows("CSVFile.csv").Activate Range("A1").Select Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Cells.Select Cells.EntireColumn.AutoFit Selection.NumberFormat = "@" Application.CutCopyMode = False</code></pre>