• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

macro code reqd

webmax

Member
Hi
i am attaching the macro code
i have wrritten the macro code for auto sum the values. In that the dollar symbol is appearing i want to remove the static which is dollar symbol.
For example in the B column=SUM(B$2:B15) i want this as SUM(B2:B15)
and also help in writing the Macro code for Fill Right the total from B Range to F Range.
regards
Shahul
 

Attachments

  • autosum macro.xls
    36.5 KB · Views: 10
Hi webmax
Maybe like this?

Code:
Sub autosum()
    Dim R As Long
    lrow = Range("B1").End(xlDown).Row
    Range("F1").End(xlDown).Offset(1).Formula = "=SUM(R[-" & (lrow - 1) & "]C:R[-1]C)"
    Range("B1").End(xlDown).Offset(1).Formula = "=SUM(R[-" & (lrow - 1) & "]C:R[-1]C)"
End Sub
 
Webmax

I like to come from the bottom up. If there is ever a blank cell in your dataset the bottom up method works nicely.


Code:
Option Explicit
Sub autosum1()
Dim lr As Long
lr = Range("B" & Rows.Count).End(xlUp).Row + 1
    Range("B" & lr & "," & "F" & lr).Value = "=SUM(R[-" & (lr - 1) & "]C:R[-1]C)"
End Sub

Try and use Option Explicit, it will help if you put the wrong variable in your VB coding (R as long) :)

Take care

Smallman
 
Hi Shahul

Provided code by Smallman is fully capable to fill data in Right..
Just need a Small Modification.. If macrcus allows me ... :)

Range("B" & lr & ":" & "F" & lr).Value = "=SUM(R[-" & (lr - 1) & "]C:R[-1]C)"
 
Back
Top