Change Macro Code with ActiveX Text Box

Appleboy

Board Regular
Joined
Sep 27, 2011
Messages
141
Hi there,

Is it possible to input an ActiveX control text box in my spreadsheet to change a certain name within my macro? For example,

Code:
If Range("C63").Value = "1" Then
    Windows("2.xls").Activate
    Range("B3:J3").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("WEEK40'11").Activate
    Range("C4").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=True
    End If

I want to change the WEEK40'11 inside this macro to WEEK41'11 when I type in WEEK41'11 to the ActiveX control text box.

Please help, thanks.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Yes. For example, if your activex text box is named textbox1, textbox1.value will return the value in the text box.

In this case, your code will be:
Windows(textbox1.value).Activate

Hope this helps.
 
Upvote 0
Hey there,

Thanks for the help. Sorry but I am rather new to excel and the whole VBA. I am wondering how can I create the text box and use that code to call?

Edit: Not sure if my text box is correct. But when I included a text box and typed in the value, it gave me an error 424 which state object is required.

This Windows("WEEK40'11").Activate is to go to the file where my macro is stored which is WEEK40'11.

Please help! :(
 
Last edited:
Upvote 0
Hi,

After much research I solved the problem myself. Using the code you provided for me, I added a Sheet1 infront of Textbox1. The code is now,

Windows(Sheet1.TextBox1.Value).Activate

Seems like you need to include where is the TextBox1 is located or else it wouldn't work.

Thanks for the help!
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,738
Members
452,940
Latest member
Lawrenceiow

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