To avoid looping through all the cells, try this:
total = WorksheetFunction.Sum(Range(ref1 & ":" & ref2))
On 23 jan, 18:24, "Khurram" <knah...@gmail.com> wrote:
> Thank you Bob, Works like a charm.
>
> Khurram
>
> Bob Phillips wrote:
> > Dim cell As Range
> > For Each cell In Range(ref1 & ":" & ref2)
> > If IsNumeric(cell.Value) Then
> > total = total + cell.Value
> > End If
> > Next cell
>
> > --
> > ---
> > HTH
>
> > Bob
>
> > (change the xxxx to gmail if mailing direct)
>
> > "Deecrypt" <knah...@gmail.com> wrote in message
> >news:(E-Mail Removed)...
> > > Hi all,
> > > Devising a macro that needs to add all the numbers up together in a
> > > given range of cells i.e Range(ref1 &":"& ref2) and assign the total to
> > > a given variable i.e total. Please let me know how I can do this.
> > > I've tried to record a macro and copy details but that shows absolute
> > > cell references whereas I'm working with relative cell references.
> > > Have also looked thgrough the newsgroups and have not found something
> > > specific to my query.
>
> > > Thank you kindly
> > > Deecrypt
|