#1
|
|||
|
|||
Help with macros, what's wrong with my code??
Hello everyone I'm new to macros and this forum(:
I'm trying to create a macro that will: get input from the user the location of the cell where the sum should appear. eg. user enters F6, macro will display the sum of cells B6:E6 in F6 and finish with the active cell being F6. Here is a snip of my code that I'm trying but it doesn't display the result. Can anyone help me? Thank you |
#2
|
|||
|
|||
Hi
If I've got it right, you want to sumarize the last four cells to the left of the selected cell, that's how it works: Code:
Sub Do_Sum() With ActiveCell If .Column > 4 Then .FormulaR1C1 = "=Sum(RC[-4]:RC[-1])" End If End With End Sub |
#3
|
|||
|
|||
Hi,
What i'm trying to do is that when the user clicks the macro have a window pop up asking in what cell do you want to display the results of adding cells B6:E6 and end up with the active cell being the cell that is displaying the results. Please help me I'm so confuse my code is not working. Thanks |
#4
|
||||
|
||||
If you're always summing B6:E6, why not have the user select the destination cell before running the macro? Much simpler than messing around with Input boxes, validating the input then changing the selection to suit.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Hi macropod,
I would love to do it like you said but unfortunately I have been ask to do it this specific way It's very frustrating ... :'( |
#6
|
||||
|
||||
At its most basic you could use something like:
Code:
Sub Demo() Application.ScreenUpdating = False Dim StrAddr As String StrAddr = Trim(InputBox("What is the Address of cell to update?", "Input Destination")) On Error GoTo ErrExit ActiveSheet.Range(StrAddr).Activate ActiveCell.Value = "=SUM(B6:E6)" ErrExit: Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Thank you so much!! you were a big help!!
Quote:
|
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
What's wrong with my loop? | Irrma | Word VBA | 2 | 06-17-2014 06:25 AM |
What's wrong with my code? | ksigcajun | Word VBA | 3 | 05-19-2014 06:42 AM |
Wrong hyphenation | NobodysPerfect | Word | 1 | 02-04-2014 05:46 AM |
Demo gone wrong | RyanNIF | Publisher | 1 | 10-19-2011 05:55 AM |
PLEASE HELP-wrong formatting???? | bruce | Word | 10 | 04-10-2010 03:45 PM |