Removing the first character using VBA

NELMO

New Member
Joined
Jun 7, 2005
Messages
9
I posted an earlier question about an Access query export to Excel putting leading apostophe (') before all data.
To remove them I thought I would use Find/Replace but the Apostophe is not recognised!

Is there a way (programmatically) to remove the first character of each data entry in each cell in a column?

thanks in advance

nel
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Indeed

You can iterate through each cell in the column and say:

Code:
Sub test()

x = 1
Do Until Cells(x, 1) = ""
Cells(x, 2) = Mid(Cells(x, 1), 2, Len(Cells(x, 1)) - 1)
x = x + 1
Loop

End Sub

This presumes we are going from cell A1, down a non-interrupted list.

Hope this helps

Patrick
 
Upvote 0
Good afternoon NELMO

How about something like this :

Code:
Sub Test()
For Each UsrCell In Selection
UsrCell.Value = Right(UsrCell.Value, Len(UsrCell.Value))
Next UsrCell
End Sub

Just highlight the range you want to remove the first character from and run the macro.

HTH

DominicB
 
Upvote 0
code works

Thats perfect

:p thanks DominicB

Sorry Andrew, :oops: didn't know whic to post too

Nel
 
Upvote 0
Two things that annoy me about this board:

1) People asking questions which have been asked hundreds, if not thousands of times in the million odd posts that exist here

2) People that do not thank everyone who contributes an answer. People dont answer these questions for their own health, or any financial reward. It's the least you could do.
 
Upvote 0

Forum statistics

Threads
1,217,332
Messages
6,135,945
Members
449,974
Latest member
riffburn

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