Discussion Locked

Excel VBA: can I edit cells in VBA?

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I am trying to write some VBA to copy data to a cell and then to edit the data in that cell. Spefically I am copying information from a CSV file that looks like this: "Some Text" and I want it to look like this: Some Text or ="Some Text". So I want to be rid of the quotations or simply change it so it is a formula for a string.

5 replies

by dklippert

Without going into detail about how you're importing the data, a rough piece of code might look like this:

Sub CleanData
Cells.Replace What:="""", Replacement:=""
End Sub

You might do better by changing the extention and then recording a macro as Excel parses the file.

Also look at:

www.cpearson.com/excel/imptext.htm

by pancras

You can place a value in cell a1 with

in current sheet
range("a1").value="Some text"

in sheet1 (not current sheet but current workbook)
sheets("sheet1").range("a1").value="some text"

"some text" can be in say a3 so
range("a1").value=Mid(Range("a3").Value, 2, Len(Range("a3").Value) - 2)
should do the trick

This discussion is closed to new replies.