Solved

vba code

Posted on 2012-03-13
4
177 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 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month5 days, 4 hours left to enroll

636 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