Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

vba code

Posted on 2012-03-13
4
Medium Priority
?
179 Views
Last Modified: 2012-03-14
Why will this not work?  AHHH

Range("d" & Rows.Count).End(xlUp).Formula = "=sum(d2:"&Range("d" & Rows.Count).End(xlUp).Range")"
0
Comment
Question by:BigWill5112
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 10

Accepted Solution

by:
Anthony Berenguel earned 2000 total points
ID: 37718308
the following has not been tested but try...
Range("d" & Rows.Count).End(xlUp).Formula = "=sum(d2:" & Range("d" & Rows.Count).End(xlUp).Range & ")"

Open in new window

0
 
LVL 10

Expert Comment

by:Anthony Berenguel
ID: 37718317
BigWill, I took a second look at your code and I'm having trouble understanding what you're trying to accomplish.

Are you trying to put your sum formula in every used cell in column D? Or are you simply summing the values in column D?
0
 
LVL 10

Expert Comment

by:Anthony Berenguel
ID: 37718331
Sub possibleSolution()

    'The following will put your sum formula in the next available cell in column D.

    'declare a string variable to hold your formula
    Dim formulaString As String
    
    'populate formulaString with formula
    formulaString = "=sum(d2:d" & Range("d" & Rows.Count).End(xlUp).Row - 1 & ")"
    Debug.Print Now & formulaString
    
    'put the formula in the next available cell in column d
    Range("d" & Rows.Count).End(xlUp).Formula = formulaString
    
End Sub

Open in new window

0
 

Author Closing Comment

by:BigWill5112
ID: 37719489
Had to do with the and symbol and spaces apparently.  thanks.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question