LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Update Current Row

First, go into design mode and change the .takefocusonclick property to false
for that commandbutton.

This will keep the activecell active.

After that, try this code in your _click event:

Option Explicit
Private Sub CommandButton1_Click()
Dim myRow As Long
Dim myVal As Variant

'ActiveCell.Select
myRow = ActiveCell.Row

Me.Cells(myRow, "B").Value = Me.Cells(myRow, "C")
With Me.Cells(myRow, "c")
.ClearContents
myVal = InputBox("Enter This Run's Figures:")
If myVal = "" Then
MsgBox "Nothing to enter"
Else
.Value = myVal
End If
End With

Me.Cells(myRow, "D").Value _
= Me.Cells(myRow, "E").Value + Me.Cells(myRow, "C").Value

End Sub

enyaw wrote:

Range("B5").Select
Selection = Range("C5")
Range("C5").Select
Selection.ClearContents

Range("C5").Select
Selection = InputBox("Enter This Runs Figures:")
If Response1 = vbYes Then

If Selection = "" Then
MsgBox "Nothing to enter"
Else
MsgBox "you cancelled"
End If
End If

ActiveSheet.Range("D5").Value = ActiveSheet.Range("E5").Value + _
ActiveSheet.Range("C5").Value

I have this code attached to a command button in G5. This works fine. My
problem is that I have more than one row that needs to be like this and i
need to be able to run the code seperately for whatever row i choose. So
there will be a number of command buttons. I need the code to run on the
same row as the command button and nowhere else. Can anyone help?


--

Dave Peterson
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
update Totals using current date BrianMcC Excel Discussion (Misc queries) 1 March 10th 07 12:16 PM
How to auto update a cell with a current date Kell2604 Excel Discussion (Misc queries) 2 June 23rd 06 09:18 PM
Automatically update charts for only the most current 12 months? AIEC33 Charts and Charting in Excel 1 February 28th 06 03:30 AM
Update current time automatically? JENNYC Excel Discussion (Misc queries) 3 July 29th 05 12:05 AM
Update Links to current Directory?? Pulcue Excel Discussion (Misc queries) 1 June 27th 05 12:11 PM


All times are GMT +1. The time now is 10:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"