LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default if elseif....

Howdie all.

I have a macro that looks for the generic contents of a choosable number of
cells.

If it finds contents, it cuts those contents from each of the cells, it then
merges the cells chosen, and pastes the values from those cells into the
merged cell group.
Thus far it works well, but I would like to modify it.

Presently, the issue I'm facing is if there are any blank cells, it inputs a
vbLf, or chr(10) input for those cells.

What I'd like to do is- if a cell is blank, I do not want a character line
return placed there.

The code for this macro is:
-----------------------------------------------------------------
Dim myRng As Range
Dim NewString As String

Set myRng = Nothing
On Error Resume Next
InputRange:
Set myRng = Application.InputBox(prompt:="Select cells to Meld", Type:=8)
If myRng Is Nothing Then End

If myRng.Cells.count 8 Then
msg = MsgBox("Invalid range selection" & vbLf & vbLf & "Please try
again", vbExclamation, "Regards, Per Jessen")
GoTo InputRange
End If

For cell = 1 To myRng.Cells.count

If NewString = "" Then
NewString = myRng.Cells(cell, 1).Value
Else
NewString = NewString & vbLf & myRng.Cells(cell, 1).Value
'this NewString allows a character return to have a new line.
'here is where I think that my modification should occur.
'I don't want rows at the end of my cell contents to be counted if there
' are no contents there.
'Elseif newstring or cell = "" then
'do not include.


End If

myRng.Cells(cell, 1).ClearContents
Next

myRng.Cells(1, 1) = NewString
myRng.MergeCells = True
myRng.WrapText = True
myRng.HorizontalAlignment = xlCenter
myRng.VerticalAlignment = xlCenter
----------------------------------------------------------------

E.g. I have 4 rows.
Rows 1, and 2 have some generic contents as text. Rows 3 and 4 have nothing
in them.
I want to only include rows one and two, but then am going to merge all 4
rows.

Thank you for your helps.
Best.
 
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
elseif Tom Ogilvy Excel Programming 3 March 28th 07 03:03 AM
IF..Then..ELSE.. ELSEIF ole_ Excel Programming 4 April 20th 05 03:59 PM
If, ElseIf mast Excel Programming 1 January 26th 05 12:11 PM
ElseIf tom1646 Excel Programming 4 October 19th 04 02:09 PM
If...Elseif...End If javab98 Excel Programming 2 July 19th 04 07:23 PM


All times are GMT +1. The time now is 01:29 AM.

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"