ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code to edit directly in cells from userform (https://www.excelbanter.com/excel-programming/276312-re-code-edit-directly-cells-userform.html)

Harald Staff[_4_]

Code to edit directly in cells from userform
 
Hi

Create a USerform1 with TextBox1, SpinButton1, CommandButton1 and CommandButton2. Userform
code:

Option Explicit

Private Sub UserForm_Initialize()
Dim R As Long
R = ActiveCell.Row
SpinButton1.Min = 1
SpinButton1.Max = 65536
SpinButton1.Value = R
CommandButton1.Caption = "delete row"
CommandButton2.Caption = "insert row"
End Sub

Private Sub CommandButton1_Click()
If ActiveCell.Row = 1 Then Exit Sub
Rows(ActiveCell.Row - 1).Delete
SpinButton1.Value = ActiveCell.Row - 1
End Sub

Private Sub CommandButton2_Click()
Rows(ActiveCell.Row).Insert Shift:=xlDown
SpinButton1.Value = ActiveCell.Row + 1
End Sub

Private Sub SpinButton1_Change()
'make something similar for columns. You fix.
Cells(SpinButton1.Value, ActiveCell.Column).Select
TextBox1.Value = ActiveCell.Formula
End Sub

Private Sub TextBox1_Change()
ActiveCell.Formula = TextBox1.Text
End Sub

--
HTH. Best wishes Harald
Excel MVP

Followup to newsgroup only please.

"GUS" wrote in message ...
I wonder if there is a worksheet or vba example that has a userform and
doing the following actions.



Bring value to userform.textbox from the selected cell when first run the
macro
Move from cell to cell with spin button or two buttons (next-previeus)
Get value from cell and then edit it trough textbox (similar to the first
action)
Add row line (above selectedcell)
Delete row line (above selectedcell)
Fit selected cell contents
Add formula to the selected cell

Is there any example with all of these (or some of these) as actions in a
userform?






All times are GMT +1. The time now is 09:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com