check for room between blank cells to paste merged range

Lowell In the south

Board Regular
Joined
Sep 26, 2002
Messages
55
Here is a bit of code the ALL knowing Rikrak helpe me with :biggrin:

Dim Rg As Range
Dim cl As Range
Range("Aq15:As16").Copy

Set Rg = Range("A10:x18")
For Each cl In Rg
If cl = "" And cl.MergeArea.Columns.Count = 1 And Not cl.EntireColumn.Hidden And Not cl.EntireRow.Hidden Then
found = True
cl.Select
Exit For
End If
Next
If found Then
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Else
MsgBox "Not enough room at top of quote contact LRBII"
End If

It copies a merged range then checks a range of cells that include hidden columns for the first blank unmerged cell that is visible then pastes the copied merged range. It works.
PROBLEM: If my copied merged range is 4 cells long and the frist blank unmerged cell is just prior to three hidden cells it will paste the copied range. when there is really not enought room to properly display the informtion.
QUESTION: How could I run a check on the next 3 cell after the first blank cell that is visible?
somthing like this??? After the first If statment?
'If (cl + the next cell) = SpecialCells(xlCellTypeVisible) Then

THANKS in advance for your help!!!!!
This message was edited by Lowell in the south on 2002-10-06 11:41
This message was edited by Lowell in the south on 2002-10-06 13:55
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Dim Rg As Range
Dim cl As Range
Range("Aq15:As16").Copy
Range("Aq15:As16").Select

cn = Range("Aq15:As16").Columns.Count
rn = Range("Aq15:As16").Rows.Count

Set Rg = Range("A10:x18")
c = Rg.Column + Rg.Columns.Count
r = Rg.Row + Rg.Rows.Count

For Each cl In Rg
If cl = "" And cl.MergeArea.Columns.Count = 1 And Not cl.EntireColumn.Hidden And Not cl.EntireRow.Hidden And cl.Column <= c - cn And cl.Row <= r - rn Then
found = True
For i = 1 To cn - 1
If cl.Offset(0, i).EntireColumn.Hidden Then found = False
Next
For i = 1 To rn - 1
If cl.Offset(i, 0).EntireRow.Hidden Then found = False
Next
If found Then Exit For
End If
Next
If found Then
cl.Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Else
MsgBox "Not enough room at top of quote contact LRBII"
End If
 
Upvote 0

Forum statistics

Threads
1,214,618
Messages
6,120,544
Members
448,970
Latest member
kennimack

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top