Filling cells using vb its Not easy to me

  • Thread starter Thread starter stakar
  • Start date Start date
S

stakar

i have to do this but i cant
In worksheet "MyOne" i have two columns
The B which contains data values and the C that it will contain th
formula =(B1-1) which it will fill all the cells till the end of the
column range (B2-1, B3-1 ...etc)

I want this to be on vb code to run fast , but i want the workshee
name "MyOne" to be refered

Example

B C
1 =(B1-1)->0
2 =(B2-1)->1
..
..
8 =7
45 =44
10 =9


Thanks in advance!!!
Stathi
 
Sub Addformula()
Dim rng as Range
With Worksheets("MyOne")
set rng = .range(.cells(1,1),.Cells(rows.count,1).End(xlup))
End with
rng.offset(0,1).Formula = "=(B1-1)"
End Sub


That should do it.
 
Hello Stathis
Sub Fillit()
Dim LastR As Long
With Sheets("MyOne")
LastR = .Range("B65536").End(xlUp).Row
.Range("C1").FormulaR1C1 = "=RC[-1]-1"
.Range("C1").AutoFill Destination:=Range("C1:C" & LastR)
End With
End Sub

HTH
Regards
Pascal
 
Thanks a lot!!
Both codes were excelent and usefull to me!!!!

See u around!!
****************************
Stathi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top