Restricting more than x number of characters in a cell....

J

J.W. Aldridge

I have a macro that refreshes a web query. The data that it pulls
changes format quite often.
Is there any way to limit the number of characters pulled or shown in
a cell/column?

Example:
(In one column)
ABCDEFG
ABCDEFG
ABCDEFG
ABCDEFG
ABCDEFG
ABCDEFG

I only want the first four characters (without running a Left formula
in another column) in the column.

Example:
ABCD
ABCD
ABCD
ABCD
ABCD
ABCD
 
G

Guest

Let's assume that you already have a routine the does the web refresh:
Sub Offer_Refreshments
Let's assume that the data refreshed goes in column A. Include a new routine:

Sub limitum()
Set rr = Intersect(ActiveSheet.UsedRange, Range("A:A"))
For Each r In rr
r.Value = Left(r.Value, 4)
Next
End Sub

Now your main routine would have code like:
Call Offer_Refreshments
Call limitum
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top