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

  • Thread starter Thread starter J.W. Aldridge
  • Start date Start date
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
 
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
 
Back
Top