Hui Man Chang
Hui Man Chang

Reputation: 7

Programming the VBA Editor

I have setting up the environment of programming the VBA Editor.

And I have a button on sheets("1"), after I click this button, I want to add the following code to sheets("2"), which sheets("2") already have some code. The code I decided would stored into string format.

Case "ABC:
    ...
    ...
    ...
    ...
End With

I want to add the code into line 15 of the sheets("2") code, but I do know how to write the code. Someone suggest me to read this tutorial http://www.cpearson.com/Excel/vbe.aspx but I cannot understand.

Clarify My Situation:

I have a database about some customer in excel, and with some code such as "case customer_1 ..... case 2 .....", which used to perform a combo box. what I want is when I add new customer in the database, press a button, a new case is automatic done, is that possible?

Can anyone write it to mee?

Upvotes: 0

Views: 185

Answers (1)

EoinS
EoinS

Reputation: 5482

Friend,

I don't believe you want your button to write code for you. Maybe this is a super advanced program that will write code depending on current state when the button is clicked but I'm assuming, based on your reading material, that you want the button to execute code for you.

In this case write some test code on sheet 2.

 Sub testthing()
 Msgbox "h3llo world!"
 End sub

Then on your sheet one button and assign testthing macro to it.

You linked a button to a macro!

Then, change the macro to perform the desired task. Test it in the project manager. When you are sure it works, change the name and assign it to your button.

This should help, but it may not. I had to do some guesswork from your question. If this doesn't answer your question please add details and we will help you

Upvotes: 1

Related Questions