View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
p45cal[_224_] p45cal[_224_] is offline
external usenet poster
 
Posts: 1
Default exporting specific cell(s)/ range


James;610481 Wrote:
I get a "Compile Error"; "Next without For" on

End If
Next cll <----
End If
End If
End Sub


Try:

Code:
--------------------

Sub ClickAddpd()
Dim rngAvailable As Range, rngCell As Range, bolSuccess As Boolean
If Range("F4") = "y" Then
Set rngAvailable = ThisWorkbook.Worksheets("Sheet1").Range("B18:B40")
For Each cll In Range("A4:C4,I4:Q4").Cells
If Application.WorksheetFunction.CountIf(rngAvailable , cll.Value) = 0 Then
For Each rngCell In rngAvailable
If rngCell.Value = vbNullString Then
rngCell.Value = cll.Value
bolSuccess = True
Exit For
End If
Next rngCell
End If
If Not bolSuccess Then
MsgBox "Ran outta spaces... couldn't place " & cll.Value & " from " & cll.Address, 0, ""
End If
Next cll
End If
End Sub

--------------------

Again untested. I'm not sure if it'll try to copy the blanks cells in
Range("A4:C4,I4:Q4")


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: 558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=169024

Microsoft Office Help