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
Solved

vba code

Posted on 2012-03-13
4
174 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
  • 3
4 Comments
 
LVL 10

Accepted Solution

by:
Anthony Berenguel earned 500 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

829 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