Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default macro over range, deleting blanks

Dear all

I want to delete blanks at the end over a range of strings. I wrote the
following macro but I am not sure about the right usage of rng. help
would be appreciated.

Sub delblanks()
Dim count As Integer, rng As range
rng = InputBox("Please type the range")
count = 0
range(rng).Select
Do While Right(rng, 1) = " "
count = count + 1
rng = Left(rng, Len(rng) - 1)
Loop
MsgBox ("there were " + count + " changes made")
End Sub

Dirk

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default macro over range, deleting blanks

Dirk,

Try this. It allows the user to select the range with the mouse

Set rng = Application.Inputbox("Please select the mouse", Type:=8)
For Each cell in rng
cell.Value = Trim(cell.Value)
Next cell

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Dirk" wrote in message
oups.com...
Dear all

I want to delete blanks at the end over a range of strings. I wrote the
following macro but I am not sure about the right usage of rng. help
would be appreciated.

Sub delblanks()
Dim count As Integer, rng As range
rng = InputBox("Please type the range")
count = 0
range(rng).Select
Do While Right(rng, 1) = " "
count = count + 1
rng = Left(rng, Len(rng) - 1)
Loop
MsgBox ("there were " + count + " changes made")
End Sub

Dirk



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting blanks Marianne Excel Discussion (Misc queries) 10 September 10th 08 10:29 AM
MACRO HELP - deleting rows containing a range of blank cells DavidHawes Excel Discussion (Misc queries) 9 February 26th 07 03:40 PM
copy range of cells with blanks then paste without blanks justaguyfromky Excel Worksheet Functions 1 September 3rd 06 07:56 PM
Deleting blanks from the end of values in cells Dave Peterson[_3_] Excel Programming 1 April 1st 04 04:51 AM
Deleting blanks from the end of values in cells Gord Dibben Excel Programming 0 April 1st 04 01:37 AM


All times are GMT +1. The time now is 01:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"