vba training london - formularc
Microsoft Office Training verified by visa - mastercard securecode about microsoft training company london ukadd this page to your favourites/bookmarksAdd to favourites
view a printable version of this pagePrintable version
email this page to somebodyEmail this page
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft VBA Training and help » vba training london - FormulaR1C1

vba training london - FormulaR1C1

The UK's most regular instructor-led training courses.
Training information: vba training london · Excel london

resolvedResolved · Low Priority · Version Standard

FormulaR1C1

Martin has attended:
Excel VBA course

by - delegate Martin [4 posts] (2007 Jul 2 Mon, 09:59) replyReply

I am trying to reference a named range in a formulaR1C1 but receive an error each time. the code is as follows:

Sub Percentages()

Dim Total As Range
Dim Counter As Integer
Dim Mycell As Range

Rows("2:2").Select
Selection.Insert Shift:=xlDown
Range("A2:F2").Select
Range("F2").Activate
Selection.Interior.ColorIndex = xlNone
Range("F2").Select


Set Total = ActiveCell
Set Mycell = ActiveCell.Offset(0, 1)

Counter = 2
Cells(Counter, 6).Activate

Do
If Cells(Counter, 6) = "" Then
Total = ActiveCell
ActiveCell.Offset(0, 1) = Mycell
Mycell.Activate

ActiveCell.FormulaR1C1 = "=sum(RC[-1]/"& Total &")"
Else
ActiveCell.Offset(0, 1) = Mycell
Mycell.Activate
ActiveCell.FormulaR1C1 = "=sum(RC[-1]/"& Total &")"
Cells(Counter, 6).Activate
Counter = Counter + 1
End If

Loop Until Cells(Counter, 6) = "end"


End Sub

The purpose of the formula is to calculate a percentage of a total that will go into the blank cell, and there will be lots of totals at irregular intervals.

Any help greatly appreciated.

Many thanks
Martin

RE: FormulaR1C1

by - trainer Carlos gold contributer[394 posts] (2007 Jul 17 Tue, 11:22) replyReply

Martin

Sorry for the delay.

I looked at your code and tried to run it on a Worksheet I set up.

In my test the system is loading a blank value into the Total variable which when trying to do the Formula is triggering an error.

I went through it using F8 and by moving row 2 down you are looking at a blank "F2" cell qand loading its value into Total.

Apart from the above, I would need to see this working on the original workbook to see where else it is going wrong.

Carlos

RE: FormulaR1C1

by - trainer Carlos gold contributer[394 posts] (2007 Jul 17 Tue, 11:25) replyReply

Martin

If you want to send the document, email it to

forum AT microsofttraining.net

Carlos

RE: FormulaR1C1

by - trainer Carlos gold contributer[394 posts] (2007 Jul 17 Tue, 15:13) replyReply

Martin

Its as I said before. The way you have the code presently you are moving the data down One line and then loading the value of a blank cell into Total which means you are dividing by it in the equation.

Run the code through using F8 (Step through) and keep flicking back tgo the Spreadsheet and watch how the data behaves.

If the moving down of the data is required then you need to rewrite the code so that the computer picks the value from any other cell except "F2" or cells (Counter, 6).

Carlos


Related articles

· What Is Microsoft Excel VBA and How Can It Help You Work Smarter?
· Company Roles in Visual Basic Training

Vba tip:

Add A New Sheet at the end of the Workbook

To add a new sheet at the end of the workbook you need to count the sheets in the workbook using:

Sheets.Count

Then use this value as the rank of the sheet after which you want to add the new sheet:

Sheets.Add After:=Sheets(Sheets.Count)

View all VBA hints and tips

Institute of IT Training - Accredited Training Provider Microsoft Certified Partner
microsoft office
Microsoft Office Specialist Authorised Testing Centre (MOS and MCAS)

Prodigy Platinum Learning Partner

Institute of IT Training - Accredited Training Provider Association of Computer Trainers Valid HTML 4.01 Transitional
Valid CSS Markup

secure online payments - visa - mastercard

Mini sitemap. These are the main areas of our web site. Full sitemap.

Training by application Main information pages See also

Access courses
DreamWeaver courses
Excel courses
MS Project courses
Outlook courses
PowerPoint courses
VBA courses
Word courses
(more...)

Public scheduled courses
On-site training
Closed company courses

Microsoft Office training
Pricing and availability
Training schedule
Training venues

Access training
Dreamweaver training
Excel training
MS Project training
PowerPoint training

London Computer Training
Computer Training London

Microsoft Access training
Microsoft Excel training
Microsoft Project training
Microsoft Outlook training
Microsoft Powerpoint training
Microsoft Word training

Time Management Course London

Interested in Access training? Please see the following pages:
microsoft access courses · microsoft training access course
microsoft+access+training · access courses in london

Training Information
AddThis Social Bookmark Button What's this?
Add to Del.icio.us Add to Facebook Add to Digg Add to Reddit Add to Google Add to Yahoo Add to Diigo Add to Mr. Wong Add to Linkarena Add to Power Oldie Add to Folkd Add to Jumptags Add to Upchuckr Add to Simpy Add to StumbleUpon Add to Slashdot Add to Netscape Add to Furl Add to Spurl Add to Blinklist Add to Blogmarks Add to Technorati Add to Newsvine Add to Blinkbits Add to Ma.Gnolia Add to Smarking Add to Netvouz