Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default HELP WITH A COUPLE OF SIMPLE FORMULAS FOR A NEW USER

A couple of simple questions. I'd appreciate some help.

1)How do I get a UserForm to open automatically when I open a
worksheet in Excel.

2)MORE IMPORTANTLY....

Can someone supply me with a VBA formula to locate the next empty cell
(or row or column) after entering data in one row to go to the next
for input. The code in the books I am referring to just plain doesn't
work.

3) ALSO MORE IMPORTANTLY
How do I get a command button on a
UserForm
on sheet1 to automatically open a UserForm
on sheet2 to
enter new data.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default HELP WITH A COUPLE OF SIMPLE FORMULAS FOR A NEW USER

Hi R,

1)How do I get a UserForm to open automatically when I open a
worksheet in Excel.


Try:

'=============
Private Sub Workbook_Open()
Userform1.Show
End Sub
'<<=============

This is workbook event code and should be pasted into
the workbook's ThisWorkbook module *not* a standard
module or a sheet module:

Right-click the Excel icon on the worksheet (or the icon
to the left of the File menu if your workbook is maximised)
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.

Can someone supply me with a VBA formula to locate the next empty cell
(or row or column) after entering data in one row to go to the next
for input. The code in the books I am referring to just plain doesn't
work.


It is invariably useful to post the problematic code.

However to return the next empty cell in column A and to
return the first empty column in row 1, try:

'================
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim iRow As Long
Dim iCol As Long

Set WB = Workbooks("MyBook.xls") '<<==== CHANGE
Set SH = WB.Sheets("Sheet1") '<<==== CHANGE

With SH
iRow = .Cells(.Rows.Count, "A").End(xlUp). _
Offset(1, 0).Row
iCol = .Cells(1, .Columns.Count).End(xlToLeft). _
Offset(0, 1).Column
End With

MsgBox Prompt:="Next row = " & iRow _
& vbNewLine _
& "Next column = " & iCol
End Sub
'<<================


3) ALSO MORE IMPORTANTLY
How do I get a command button on a
UserForm
on sheet1 to automatically open a UserForm
on sheet2 to
enter new data.



In the first Userform's code module try something like:

'=============
Private Sub CommandButton1_Click()
Me.Hide
UserForm2.Show
End Sub
'<<============


---
Regards,
Norman


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default HELP WITH A COUPLE OF SIMPLE FORMULAS FOR A NEW USER

On Apr 14, 5:58 pm, "Norman Jones"
wrote:
Hi R,

1)How do I get a UserForm to open automatically when I open a
worksheet in Excel.


Try:

'=============
Private Sub Workbook_Open()
Userform1.Show
End Sub
'<<=============

This is workbook event code and should be pasted into
the workbook's ThisWorkbook module *not* a standard
module or a sheet module:

Right-click the Excel icon on the worksheet (or the icon
to the left of the File menu if your workbook is maximised)
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.

Can someone supply me with a VBA formula to locate the next empty cell
(or row or column) after entering data in one row to go to the next
for input. The code in the books I am referring to just plain doesn't
work.


It is invariably useful to post the problematic code.

However to return the next empty cell in column A and to
return the first empty column in row 1, try:

'================
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim iRow As Long
Dim iCol As Long

Set WB = Workbooks("MyBook.xls") '<<==== CHANGE
Set SH = WB.Sheets("Sheet1") '<<==== CHANGE

With SH
iRow = .Cells(.Rows.Count, "A").End(xlUp). _
Offset(1, 0).Row
iCol = .Cells(1, .Columns.Count).End(xlToLeft). _
Offset(0, 1).Column
End With

MsgBox Prompt:="Next row = " & iRow _
& vbNewLine _
& "Next column = " & iCol
End Sub
'<<================

3) ALSO MORE IMPORTANTLY
How do I get a command button on a
UserForm
on sheet1 to automatically open a UserForm
on sheet2 to
enternewdata.


In the first Userform's code module try something like:

'=============
Private Sub CommandButton1_Click()
Me.Hide
UserForm2.Show
End Sub
'<<============

---
Regards,
Norman


THANKS FOR YOUR HELP

THIS IS WHAT HAPPENED NEXT

This is the code I've tried (I already have items in rows 1-4 and I
just want to add onto the next one)

Public Sub Tester()
Dim Fiddling As Workbook
Dim shtProductAdd As Worksheet
Dim iRow As Long
Dim iCol As Long
Set Fiddling = Workbooks("Fiddling.xls")
Set shtProductAdd = Fiddling.Worksheets("products")
With shtProductAdd
iRow = .Cells(.Rows.Count, "A").End(xlUp). _
Offset(1, 0).Row
iCol = .Cells(1, .Columns.Count).End(xlToLeft). _
Offset(0, 1).Column
End With
MsgBox Prompt:="Next row = " & iRow _
& vbNewLine _
& "Next column = " & iCol
End Sub

Private Sub NameButton_Click()
Dim strNameButton As String
Dim curBoxPrice As Currency
Dim intUnitNumber As Integer
Dim curSalePrice As Currency


Set shtProductAdd =
Application.Workbooks("Fiddling.xls").Worksheets(" products")

strNameButton = InputBox("Please Enter Product Name")
shtProductAdd.Range("A5") = strNameButton
curBoxPrice = InputBox("Please Enter Box Price")
shtProductAdd.Range("B5") = curBoxPrice
intUnitNumber = InputBox("UNITS")
shtProductAdd.Range("C5") = intUnitNumber
curSalePrice = InputBox("Enter Sale Price")
shtProductAdd.Range("D5") = curSalePrice
End Sub
Private Sub ExitButon_Click()
Unload ProductForm
End Sub

Which returns me to only ever updating one single row (the 5 row
obviously)
The same as before I tried my latest bit of code to update the row and
move down
None of the code forms Ive tried from any text book has ever worked.
I know why I only do row 5 but Ive tried it with
ShtProductAdd (A:A")
You know what happened

Ive tried it with no data on the worksheet
and
ShtProductAdd("A")

Which returned

Method range of object worksheet failed

NEXT

To get a button called ClientButton2 on a userform on sheet 1

To open sheet 2 and go to a command button on the sheet which
Opens a new userform on sheet 2

I've tried

Private Sub ClientButton2_Click() 'this is on sheet1

Dim MenuButton As CommandButton
Me.Hide
MenuButton.Show 'command button on
sheet2

End Sub

Which gives me
Object variable or With block variable not set

Ive also got a listbox on the userform on sheet2 with this code


Private Sub ClientForm_Initialize() 'the userform on sheet2

Dim ListBox1 As ListBox
'select ............default list box
IstId.ListIndex = 0
'select default option button
'optTotal.Value = True
ListBox1.AddItem "M&M's plain (500g)"
ListBox1.AddItem "M&M's peanut (500g)"
ListBox1.AddItem "Cadbury Chocolate Bars (600g)"
End Sub




But none of my products shows in the listbox which remains empty



IF YOU COULD HELP ME WITH THIS I'D BE GRATEFUL

ID FATHER RATHER HAVE NEW NEWS EMAILED TO
if possible rather than a newsgroup

Reply
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
Simplifying a couple of formulas fryguy Excel Worksheet Functions 2 December 3rd 06 06:47 PM
User Form Help Seems Simple Brandon Johnson Excel Programming 5 June 6th 06 03:34 PM
Simple IF Statement Q - Ditzy User bleu808 Excel Discussion (Misc queries) 1 January 13th 06 12:34 AM
New user with a couple of questions.... B Craig Excel Discussion (Misc queries) 6 February 11th 05 10:15 PM
New Excel user needs help with simple Macro... Rahim Kassam New Users to Excel 1 January 24th 05 02:10 PM


All times are GMT +1. The time now is 07:40 PM.

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

About Us

"It's about Microsoft Excel"