Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Empty cell range and error 91

My sheet called "Names" have a list of things in two ranges (B8:B37,D8:D37)
and some of the cells are empty. I need to copy the list from the two ranges
to, for
example, in B12:B41 on sheet "Attendance" without the empty cells. I know
that the range on sheet 2 is smaller than the range on sheet1. This is
because I have two list of name depend of the employee contract type but
never the total of the sum of both will be more than 30.
-----------------------------------------------------------------------------------------------
Sub COPY()

Dim rngN1 as Range

Set rngN1 = Sheets("Names").Range("B8:B37,D8:D37")

If Not rngN1 Is Nothing Then
TempN = rngN1
With Temp
.Copy Destination:=Sheets("Attendance").Range("B12:B41")
End With
End If

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Empty cell range and error 91

abdrums,

It is a bad idea to name a sub with a key word like "Copy".... Anyway,
simply step through the filled cells like so:

Sub CopySub()
Dim rngN1 As Range
Dim myCell As Range
Dim i As Integer

Set rngN1 = Sheets("Names").Range("B8:B37,D8:D37")

i = 1

For Each myCell In rngN1.SpecialCells(xlCellTypeConstants)
myCell.Copy Destination:=Sheets("Attendance").Range("B12:B41") .Cells(i)
i = i + 1
Next myCell

End Sub


HTH,
Bernie
MS Excel MVP

"abdrums" wrote in message
...
My sheet called "Names" have a list of things in two ranges
(B8:B37,D8:D37)
and some of the cells are empty. I need to copy the list from the two
ranges
to, for
example, in B12:B41 on sheet "Attendance" without the empty cells. I know
that the range on sheet 2 is smaller than the range on sheet1. This is
because I have two list of name depend of the employee contract type but
never the total of the sum of both will be more than 30.
-----------------------------------------------------------------------------------------------
Sub COPY()

Dim rngN1 as Range

Set rngN1 = Sheets("Names").Range("B8:B37,D8:D37")

If Not rngN1 Is Nothing Then
TempN = rngN1
With Temp
.Copy Destination:=Sheets("Attendance").Range("B12:B41")
End With
End If

End Sub



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
If cell not empty, then display from range puiuluipui Excel Discussion (Misc queries) 7 October 3rd 09 08:01 PM
Replace Error with Empty Cell raparipa Excel Programming 2 October 24th 06 09:19 PM
Trapping error from Empty Dynamic Named Range Casey[_105_] Excel Programming 5 June 13th 06 03:43 PM
Finding next empty empty cell in a range of columns UncleBun Excel Programming 1 January 13th 06 11:22 PM
select first empty cell in a range Shawn Excel Programming 2 September 13th 05 12:14 AM


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