Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Left Justify Rows of Numbers

I have a table in which each cell contains either a number or is blank.
On each row, I would like to delete all the blank cells to the left of
the first number and shift cells left.

Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Left Justify Rows of Numbers

Off the top

For Each cell in Selection
cell.Value = Trim(cell.Value)
cell.Numberformat = "@"
Next cell

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"JG Scott" wrote in message
oups.com...
I have a table in which each cell contains either a number or is blank.
On each row, I would like to delete all the blank cells to the left of
the first number and shift cells left.

Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,316
Default Left Justify Rows of Numbers

The following example assumes that the 2 columns of data are Columns A and B
and it starts running with the cellpointer in first value in column B
================================================== ====
Sub MoveToBlankCell()

Dim wb As Workbook
Dim ws As Worksheet
Dim varVal As Variant
Dim iRowCounter As Integer

Set wb = ActiveWorkbook
Set ws = wb.Sheets("Sheet1")

Range("B1").Select

varVal = ActiveCell.Value

Do Until varVal = ""
If ActiveCell.Offset(iRowCounter, -1).Value = "" Then
ActiveCell.Offset(iRowCounter).Cut
ActiveCell.Offset(iRowCounter, -1).Delete Shift:=xlShiftToLeft
End If
iRowCounter = iRowCounter + 1
varVal = ActiveCell.Offset(iRowCounter).Value
Loop

Set wb = Nothing
Set ws = Nothing

End Sub
================================================== ====
--
Kevin Backmann


"JG Scott" wrote:

I have a table in which each cell contains either a number or is blank.
On each row, I would like to delete all the blank cells to the left of
the first number and shift cells left.

Thanks.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Left Justify Rows of Numbers

Bob,

Thanks, but I think you misunderstand. I am not trying to delete
blanks within cells, but rather to delete blank cells entirely and
shift cells to the left.

JG Scott

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
Left Justify category axis Alex Charts and Charting in Excel 1 March 6th 08 08:12 PM
Right/Left Justify within a cell Judi Excel Discussion (Misc queries) 5 July 30th 07 08:32 PM
left justify a legend SHoagburg Charts and Charting in Excel 0 June 14th 05 08:00 PM
Left Justify Caption on a Button Linda Mac Excel Programming 1 August 25th 04 09:16 PM
Left Justify Cell Ron K Excel Programming 2 September 26th 03 08:35 PM


All times are GMT +1. The time now is 02:50 AM.

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

About Us

"It's about Microsoft Excel"