?
Solved

Vb help

Posted on 2011-02-14
4
Medium Priority
?
221 Views
Last Modified: 2012-06-22
Please can you help, I'm trying to change the code on the userform.

I want Textbox2 to equal the value held in "DataSheet!B4" and then (+1). So if B4 was equal to "AA-1" when the user form opens the value displayed in textbox2 would be "AA-2"

Private Sub UserForm_Initialize()
TextBox1.Text = VBA.Environ("USERNAME")
TextBox2.Text = "DataSheet!B4"
   
End Sub
 example2.xls
0
Comment
Question by:Gazza83
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 50

Expert Comment

by:Dave Brett
ID: 34893310
hth

Dave
Private Sub UserForm_Initialize()
    Dim sArr
    TextBox1.Text = VBA.Environ("USERNAME")
    sArr = Split(Sheets("Data").[B4].Value, "-")
    TextBox2.Text = Val(sArr(1) + 1)
End Sub

Open in new window

0
 
LVL 50

Accepted Solution

by:
Dave Brett earned 2000 total points
ID: 34893314
for complete string.

Dave
Private Sub UserForm_Initialize()
    Dim sArr
    TextBox1.Text = VBA.Environ("USERNAME")
    sArr = Split(Sheets("Data").[B4].Value, "-")
    TextBox2.Text = sArr(0) & "-" & Val(sArr(1) + 1)
End Sub

Open in new window

0
 
LVL 3

Expert Comment

by:OblivionSY
ID: 34893326
I am not sure that code re-creates the exact code required.

Private Sub UserForm_Initialize()
    Dim sArr
    TextBox1.Text = VBA.Environ("USERNAME")
    sArr = Split(Sheets("Data").[B4].Value, "-")
    TextBox2.Text = sArr(0) & "-" & Val(sArr(1) + 1)
End Sub

Open in new window

0
 
LVL 3

Expert Comment

by:OblivionSY
ID: 34893329
Beat me to it :-)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question