Solved

Vb help

Posted on 2011-02-14
4
202 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
  • 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 500 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now