View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default How to skip empty cells while running a macro?

Hi
not tested but try something like

sub foo()
dim rng as range
dim cell as range

set rng=activesheet.range("E1:E100")
for each cell in rng
if cell.value<"" and cell.value<5 then
cell.offset(0,-4).resize(1,4).value = _
worksheets("sheet2").range("A1:D1").value
end if
next
end sub


--
Regards
Frank Kabel
Frankfurt, Germany


I want my macro to skip an empty cell and go to next if there is no
(numerical) data in the cell. Can you Please tell me how can I
include this in my macro.
I am want my macro to be precise with least amount of lines.
Here is what I am doing:
select cell
if value is < than say 5
select 4 cells to its left copy (I am giving relative cell address)
goto another sheet,
select a range
insert copied cells
goback to sheet
goto next cell ( down)
do the same
if no data stop macro

Thank you for helping.


---
Message posted from http://www.ExcelForum.com/