Macro help. Newbie

Matty2470

New Member
Joined
Mar 7, 2002
Messages
24
HI, I have just started using excel after becominreasonable profficient in Access.

Eeeeek, there are no do it your self cut and paste macros! Ouch!

Here is what I need. I need to know how to clear a row in a table from a for in another worksheet. This worksheet contains textboxes and drop down menus which link to tables in other worksheets. I want to put a command button on the main form whcih will clear all the contents of these text boxes and the cells they link to.

It would be ideal that a refresh - clear contents fromm these rows acts on iniciation of the workbook.

Also, I would like to open different worksheets from command buttons on the main form.

Sorry. Am I asking too much? I am just starting out

Thanks

Mathew
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Here is what I need. I need to know how to clear a row in a table from a for in another worksheet. This worksheet contains textboxes and drop down menus which link to tables in other worksheets. I want to put a command button on the main form whcih will clear all the contents of these text boxes and the cells they link to.
Something like:
TextBox1.Text = ""
will clear the contents of your text box. If the text box is linked to a cell, it should automatically clear out that cell as well. Of course, you could also clear the cell using:
Range("A1").ClearContents

It would be ideal that a refresh - clear contents fromm these rows acts on iniciation of the workbook.
If you mean you want to clear out certain rows each time the workbook is opened, you could put this in the workbook's code:

Private Sub Workbook_Open()
Sheets("Sheet1").Rows("2:3").ClearContents
End Sub

and change the sheet and row references to your requirements.

Also, I would like to open different worksheets from command buttons on the main form.
Attach code to your button that resembles this:

Private Sub CommandButton1_Click()
Workbooks.Open FileName:= _
"C:Book1.xls"
End Sub


If you need any further help just let me know.

Regards,
 
Upvote 0
Also, I would like to open different worksheets from command buttons on the main form.


--------------------------------------------------------------------------------


Thank you very much. Everything works apart from:
the last part

I want to open different worksheets in the same workbook from command buttons on sheet one - not open workbooks.


This part Attach code to your button that resembles this:

Private Sub CommandButton1_Click()
Workbooks.Open FileName:= _
"C:Book1.xls"
End Sub

PLease help.

Mathew
 
Upvote 0
On 2002-03-09 10:21, Matty2470 wrote:
Also, I would like to open different worksheets from command buttons on the main form.


--------------------------------------------------------------------------------


Thank you very much. Everything works apart from:
the last part

I want to open different worksheets in the same workbook from command buttons on sheet one - not open workbooks.


This part Attach code to your button that resembles this:

Private Sub CommandButton1_Click()
Workbooks.Open FileName:= _
"C:Book1.xls"
End Sub

PLease help.

Mathew
Mathew, I assume you mean you want to activate different worksheets in the same workbook (you can't open a worksheet). If my assumption is correct, try this:

<pre>
Private Sub CommandButton1_Click()
Sheets("Sheet3").Activate
End Sub
</pre>

This will activate Sheet3.

Is this what you are looking for?
 
Upvote 0

Forum statistics

Threads
1,213,524
Messages
6,114,117
Members
448,549
Latest member
brianhfield

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top