View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default If then statement

assumes the text values in column B are constants and not produced by
formulas.


Sub copydata()
Dim rng as Range, rng1 as Range, rng2 as Range
Dim rng3 as Range
with worksheets("Data Input")
set rng = .Range("B19:57").SpecialCells(xlConstants,xlTextVa lues)
if not rng is nothing then
set rng1 = Intersect(rng.entireRow,.Columns(1).Resize(,2))
set rng2 = Intersect(rng.entireRow,.Columns(4))
else
exit sub
end if
end with
set rng3 = workbooks("Pending and Short.xls") _
.Worksheets("Pending").Cells(rows.count,2).End(xlu p)(2)
rng1.copy rng3.offset(0,-1)
rng2.copy rng3.offset(0,2)

--
Regards,
Tom Ogilvy



"SITCFanTN" wrote:

I'm not familiar with if then statements, although I've heard of them so I'm
thinking that is what I need for this situation.

What I need to do is copy the text from the active sheet called "Data
Input". I need to copy the cells from Rows 19 - 57, Col A, B and D, only if
there is text in column B and copy it to a new workbook titled "Pending and
Short", to sheet called "Pending". It would copied to the next available row
where Col B is empty.
I know I need to concatenate the column text into Col B and not sure of
that either. Thanks for your help in advance.