View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Looping thru a range - storing IF not blank?

Maybe something like:

Option Explicit
sub testme01()

dim myCommentCells as Range
dim oRow as long
dim myCell as range

with worksheets("sheet1")
set mycommentcells = .range("a1:a5,c3:c9,d5:d44")
end with

orow = 1
for each mycell in mycommentcells.cells
if trim(mycell.value) = "" then
'do nothing
else
worksheets("sheet2").cells(orow,"A").value = mycell.value
orow = orow + 1
end if
next mycell

end sub




Alex Coker wrote:

Can anyone help with this task? I have never used VBA, but I am a
programmer.

I have a worksheet of survey results. It has five questions and allows for
five answers and comments. I want to consequtively report the comments to
the employee in a report. In other words, I have a range of comment cells,
some of which have content (most do not). I want to loop through the range
and when the comment cell has content, store it in another cell.

If you need more information, please ask.

Thanks,
Alex


--

Dave Peterson