if macro

  • Thread starter Thread starter Sam
  • Start date Start date
S

Sam

in column a , from a2 i have dates

in column b , from b2 , i have stock price

in column c , from c2 , i have nasdaq values

my data length will change ....may be 100 rows of data or 10000...

what i m looking for is a macro do to :

if values in cells in column c are > 0

then in column d i want those dates
in column e i want corr values from column b and in column F i want column c
values....


sam
 
No need to use a macro, use a formula

in D2 put int
=if($c2>0,A2,"")
in E2
=if($C2>0,B2,"")

in F2
=if($C2>0,F2,"")

then select D2:F2 and drag fill down the column


with code

Dim rng as Range
set rng = Range(Cells(2,1),Cells(rows.count,1).End(xlup))
rng.offset(3,0).Resize(,3).formula = "=($C2>0,A2,"""")"
' to make hard coded values rather than formulas - optional
'rng.offset(0,3).Resize(,3).Formula = rng.offset(0,3).Resize(,3).Value


Should do it.
 
Back
Top