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: 8
Default Looping with multiple conditions in Userform

I'm developing a userform for a resolutions tracking table. The userform
inputs data into a series of named ranges comprising a two-row area,
inserting new rows and merging cells as necessary to contain all of the data.

When the user clicks OK, I want the data in the target cell in Column B
("adoptedbywhom") to wrap into the cells below, but only after checking
whether there are enough rows in the two-row area to contain the text; if
more rows are needed, it should insert an new row within the two-row area so
that when the target cell is merged with the two cells below it, the data
remains inside the original two-row area (now expanded by one row).

For some reason, I can't get the userform to enter that new row:

Sub Testing()

Dim SelRange As Range
Dim ResRange As Range
Dim RowNum As Integer

Set SelRange = Range("adoptedbywhom")
Set ResRange = Range("resolutionsynopsis", "resolutiondescription")

If (Len(SelRange.Text) / SelRange.ColumnWidth) 1 Then

If (Len(ResRange.Text) / ResRange.ColumnWidth) <= (Len(SelRange.Text) /
SelRange.ColumnWidth) Then

For RowNum = 1 To CInt((Len(SelRange.Text) / SelRange.ColumnWidth) +
2)

Range("resolutiondescription").Rows.Insert
Application.Goto "adoptedbywhom"
With selection
.Resize(selection.Rows.Count + 1, _
selection.Columns.Count).Merge
.WrapText = True
End With

Next RowNum

Else
For RowNum = 1 To CInt((Len(SelRange.Text) / SelRange.ColumnWidth) +
2)

With selection
.Resize(selection.Rows.Count + 1, _
selection.Columns.Count).Merge
.WrapText = True
End With

Next RowNum

End If

End If


End Sub
 
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
Looping through images on a userform Zarch Excel Programming 4 October 1st 07 11:19 PM
Looping with Userform WLMPilot Excel Programming 4 November 28th 06 03:07 PM
help looping through textboxs on userform funkymonkUK[_168_] Excel Programming 4 May 22nd 06 11:19 AM
Looping procedure calls userform; how to exit loop (via userform button)? KR Excel Programming 6 July 27th 05 12:57 PM
looping through all checkbox's in a userform strataguru[_3_] Excel Programming 1 October 7th 03 05:01 PM


All times are GMT +1. The time now is 08:03 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"