Excel VBA | Userform that updates an selected row on an ListboxHow to avoid using Select in Excel VBAVBA Excel - Update control on a dynamicaly addressed userformInitialize Excel Userform with VariableExcel VBA - Search Userform Listbox with Multiple Columns via textboxVBA Excel 2013: Assign Array Values from Another UserFormVBA - Referencing userform name from cell value variableCan an Excel cell formula refer to a UserForm control?VBA: Userform Textbox_Change Only Works OnceCopy and delete selected listbox itemSearch 2 criteria in ListBox in VBA Excel

On the origin of "casa"

CBP interview, how serious should I take it?

What is this grasshopper doing?

What does the "thaumaturgy hazard trefoil" look like?

Random point on a sphere

Is it appropriate for a professor to require students to sign a non-disclosure agreement before being taught?

Why are walk-ins for Global Entry interview typically only accepted when arriving from an international flight?

How flexible are number-of-pages submission guidelines for conferences?

What is going on: C++ std::move on std::shared_ptr increases use_count?

How to progress with CPLEX/Gurobi

Are there any space probes or landers which regained communication after being lost?

How can I protect myself in case of a human attack like the murders of the hikers Jespersen and Ueland in Morocco?

Why was "leaping into the river" a valid trial outcome to prove one's innocence?

Does the mana ability restriction of Pithing Needle refer to the cost or the effect of an activated ability?

Procedure for traffic not in sight

Why does F + F' = 1?

Stack class in Java 8

What is the platform on the side of Me'arat Hamachpela?

Is there any detail about ambulances in Star Wars?

Is there a standard terminology for female equivalents of terms such as 'Kingdom' and if so, what are the most common terms?

SCOTUS - Can Congress overrule Marbury v. Madison by statute?

How does instantaneous velocity or acceleration have any other numerical value than 0?

For how long could UK opposition parties prevent new elections?

Does the word “uzi” need to be capitalized?



Excel VBA | Userform that updates an selected row on an Listbox


How to avoid using Select in Excel VBAVBA Excel - Update control on a dynamicaly addressed userformInitialize Excel Userform with VariableExcel VBA - Search Userform Listbox with Multiple Columns via textboxVBA Excel 2013: Assign Array Values from Another UserFormVBA - Referencing userform name from cell value variableCan an Excel cell formula refer to a UserForm control?VBA: Userform Textbox_Change Only Works OnceCopy and delete selected listbox itemSearch 2 criteria in ListBox in VBA Excel






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I'm working on a basic userform project to learn and use it on my actual database for business.



a. I have created two userforms;



  • UserForm1 = Adding data to last row, show data on a listbox and deletes a row

  • UserForm2 = You can open it from on UserForm1 (I named "Edit")

b. The data that I have basically 4 columns and values;



ID || Name || Last Name || Date


When you click the "Edit" button on that and the row that you want to update data on listbox, it will open 3 textboxes with which you can change ID, Name, and Last Name. Additionally there is a "Save" button



I have a code that I made with an youtuber but what he did was he remains the ID column with Label and you can not change it, just shows the value.



What I want to do is I want to change all values (ID, Name, Last Name) not just Name and Last Name?
I tried and searched a lot but what all I did had not worked. Here is my code;



The Edit Button's code on UserForm1



Private Sub CommandButton4_Click()
UserForm2.Label4.Caption = ListBox1.List(ListBox1.ListIndex) ' I wanted to update this data also
UserForm2.TextBox1.Text = ListBox1.Column(1, ListBox1.ListIndex)
UserForm2.TextBox2.Text = ListBox1.Column(2, ListBox1.ListIndex)
UserForm2.Show
End Sub


Save Button Code on UserForm2



'When I make changes on this, It updates all rows with the entered values. This is original code that I want to make changes.

Private Sub CommandButton2_Click()
Dim i As Integer

For i = 2 To Range("A10000").End(xlUp).Row
If Cells(i, 1) = Label4.Caption Then
Cells(i, 2) = TextBox1.Text
Cells(i, 3) = TextBox2.Text
End If
Next i

MsgBox "Saved!", vbInformation
Unload Me
End Sub









share|improve this question


























  • So right now you have two textboxes and one label, and you wish to have three textboxes instead? Why not replace the label by a textbox then?

    – Tim Stack
    Mar 28 at 8:05











  • Yep, I had tried it but after that I have to change the If statement. So I got stuck on that. I couldn't understand to what to write on UserForm2

    – orange
    Mar 28 at 8:11












  • Well if you remove the label then If Cells(i, 1) = Label4.Caption Then becomes nonsense as there is no label to refer to

    – Tim Stack
    Mar 28 at 8:18











  • So will be work like this? For i = 2 To Range("A10000").End(xlUp).Row If Cells(i, 1) = TextBox1.Text Then Cells(i, 2) = TextBox2.Text Cells(i, 3) = TextBox3.Text End If Next i

    – orange
    Mar 28 at 9:38






  • 1





    Are you sure you are referring to the correct textbox? Use F8 to step through the code to see what values you are comparing with

    – Tim Stack
    Mar 28 at 9:44

















0















I'm working on a basic userform project to learn and use it on my actual database for business.



a. I have created two userforms;



  • UserForm1 = Adding data to last row, show data on a listbox and deletes a row

  • UserForm2 = You can open it from on UserForm1 (I named "Edit")

b. The data that I have basically 4 columns and values;



ID || Name || Last Name || Date


When you click the "Edit" button on that and the row that you want to update data on listbox, it will open 3 textboxes with which you can change ID, Name, and Last Name. Additionally there is a "Save" button



I have a code that I made with an youtuber but what he did was he remains the ID column with Label and you can not change it, just shows the value.



What I want to do is I want to change all values (ID, Name, Last Name) not just Name and Last Name?
I tried and searched a lot but what all I did had not worked. Here is my code;



The Edit Button's code on UserForm1



Private Sub CommandButton4_Click()
UserForm2.Label4.Caption = ListBox1.List(ListBox1.ListIndex) ' I wanted to update this data also
UserForm2.TextBox1.Text = ListBox1.Column(1, ListBox1.ListIndex)
UserForm2.TextBox2.Text = ListBox1.Column(2, ListBox1.ListIndex)
UserForm2.Show
End Sub


Save Button Code on UserForm2



'When I make changes on this, It updates all rows with the entered values. This is original code that I want to make changes.

Private Sub CommandButton2_Click()
Dim i As Integer

For i = 2 To Range("A10000").End(xlUp).Row
If Cells(i, 1) = Label4.Caption Then
Cells(i, 2) = TextBox1.Text
Cells(i, 3) = TextBox2.Text
End If
Next i

MsgBox "Saved!", vbInformation
Unload Me
End Sub









share|improve this question


























  • So right now you have two textboxes and one label, and you wish to have three textboxes instead? Why not replace the label by a textbox then?

    – Tim Stack
    Mar 28 at 8:05











  • Yep, I had tried it but after that I have to change the If statement. So I got stuck on that. I couldn't understand to what to write on UserForm2

    – orange
    Mar 28 at 8:11












  • Well if you remove the label then If Cells(i, 1) = Label4.Caption Then becomes nonsense as there is no label to refer to

    – Tim Stack
    Mar 28 at 8:18











  • So will be work like this? For i = 2 To Range("A10000").End(xlUp).Row If Cells(i, 1) = TextBox1.Text Then Cells(i, 2) = TextBox2.Text Cells(i, 3) = TextBox3.Text End If Next i

    – orange
    Mar 28 at 9:38






  • 1





    Are you sure you are referring to the correct textbox? Use F8 to step through the code to see what values you are comparing with

    – Tim Stack
    Mar 28 at 9:44













0












0








0








I'm working on a basic userform project to learn and use it on my actual database for business.



a. I have created two userforms;



  • UserForm1 = Adding data to last row, show data on a listbox and deletes a row

  • UserForm2 = You can open it from on UserForm1 (I named "Edit")

b. The data that I have basically 4 columns and values;



ID || Name || Last Name || Date


When you click the "Edit" button on that and the row that you want to update data on listbox, it will open 3 textboxes with which you can change ID, Name, and Last Name. Additionally there is a "Save" button



I have a code that I made with an youtuber but what he did was he remains the ID column with Label and you can not change it, just shows the value.



What I want to do is I want to change all values (ID, Name, Last Name) not just Name and Last Name?
I tried and searched a lot but what all I did had not worked. Here is my code;



The Edit Button's code on UserForm1



Private Sub CommandButton4_Click()
UserForm2.Label4.Caption = ListBox1.List(ListBox1.ListIndex) ' I wanted to update this data also
UserForm2.TextBox1.Text = ListBox1.Column(1, ListBox1.ListIndex)
UserForm2.TextBox2.Text = ListBox1.Column(2, ListBox1.ListIndex)
UserForm2.Show
End Sub


Save Button Code on UserForm2



'When I make changes on this, It updates all rows with the entered values. This is original code that I want to make changes.

Private Sub CommandButton2_Click()
Dim i As Integer

For i = 2 To Range("A10000").End(xlUp).Row
If Cells(i, 1) = Label4.Caption Then
Cells(i, 2) = TextBox1.Text
Cells(i, 3) = TextBox2.Text
End If
Next i

MsgBox "Saved!", vbInformation
Unload Me
End Sub









share|improve this question
















I'm working on a basic userform project to learn and use it on my actual database for business.



a. I have created two userforms;



  • UserForm1 = Adding data to last row, show data on a listbox and deletes a row

  • UserForm2 = You can open it from on UserForm1 (I named "Edit")

b. The data that I have basically 4 columns and values;



ID || Name || Last Name || Date


When you click the "Edit" button on that and the row that you want to update data on listbox, it will open 3 textboxes with which you can change ID, Name, and Last Name. Additionally there is a "Save" button



I have a code that I made with an youtuber but what he did was he remains the ID column with Label and you can not change it, just shows the value.



What I want to do is I want to change all values (ID, Name, Last Name) not just Name and Last Name?
I tried and searched a lot but what all I did had not worked. Here is my code;



The Edit Button's code on UserForm1



Private Sub CommandButton4_Click()
UserForm2.Label4.Caption = ListBox1.List(ListBox1.ListIndex) ' I wanted to update this data also
UserForm2.TextBox1.Text = ListBox1.Column(1, ListBox1.ListIndex)
UserForm2.TextBox2.Text = ListBox1.Column(2, ListBox1.ListIndex)
UserForm2.Show
End Sub


Save Button Code on UserForm2



'When I make changes on this, It updates all rows with the entered values. This is original code that I want to make changes.

Private Sub CommandButton2_Click()
Dim i As Integer

For i = 2 To Range("A10000").End(xlUp).Row
If Cells(i, 1) = Label4.Caption Then
Cells(i, 2) = TextBox1.Text
Cells(i, 3) = TextBox2.Text
End If
Next i

MsgBox "Saved!", vbInformation
Unload Me
End Sub






excel vba userform






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 9:51









Tim Stack

2,3071 gold badge6 silver badges28 bronze badges




2,3071 gold badge6 silver badges28 bronze badges










asked Mar 28 at 8:00









orangeorange

102 bronze badges




102 bronze badges















  • So right now you have two textboxes and one label, and you wish to have three textboxes instead? Why not replace the label by a textbox then?

    – Tim Stack
    Mar 28 at 8:05











  • Yep, I had tried it but after that I have to change the If statement. So I got stuck on that. I couldn't understand to what to write on UserForm2

    – orange
    Mar 28 at 8:11












  • Well if you remove the label then If Cells(i, 1) = Label4.Caption Then becomes nonsense as there is no label to refer to

    – Tim Stack
    Mar 28 at 8:18











  • So will be work like this? For i = 2 To Range("A10000").End(xlUp).Row If Cells(i, 1) = TextBox1.Text Then Cells(i, 2) = TextBox2.Text Cells(i, 3) = TextBox3.Text End If Next i

    – orange
    Mar 28 at 9:38






  • 1





    Are you sure you are referring to the correct textbox? Use F8 to step through the code to see what values you are comparing with

    – Tim Stack
    Mar 28 at 9:44

















  • So right now you have two textboxes and one label, and you wish to have three textboxes instead? Why not replace the label by a textbox then?

    – Tim Stack
    Mar 28 at 8:05











  • Yep, I had tried it but after that I have to change the If statement. So I got stuck on that. I couldn't understand to what to write on UserForm2

    – orange
    Mar 28 at 8:11












  • Well if you remove the label then If Cells(i, 1) = Label4.Caption Then becomes nonsense as there is no label to refer to

    – Tim Stack
    Mar 28 at 8:18











  • So will be work like this? For i = 2 To Range("A10000").End(xlUp).Row If Cells(i, 1) = TextBox1.Text Then Cells(i, 2) = TextBox2.Text Cells(i, 3) = TextBox3.Text End If Next i

    – orange
    Mar 28 at 9:38






  • 1





    Are you sure you are referring to the correct textbox? Use F8 to step through the code to see what values you are comparing with

    – Tim Stack
    Mar 28 at 9:44
















So right now you have two textboxes and one label, and you wish to have three textboxes instead? Why not replace the label by a textbox then?

– Tim Stack
Mar 28 at 8:05





So right now you have two textboxes and one label, and you wish to have three textboxes instead? Why not replace the label by a textbox then?

– Tim Stack
Mar 28 at 8:05













Yep, I had tried it but after that I have to change the If statement. So I got stuck on that. I couldn't understand to what to write on UserForm2

– orange
Mar 28 at 8:11






Yep, I had tried it but after that I have to change the If statement. So I got stuck on that. I couldn't understand to what to write on UserForm2

– orange
Mar 28 at 8:11














Well if you remove the label then If Cells(i, 1) = Label4.Caption Then becomes nonsense as there is no label to refer to

– Tim Stack
Mar 28 at 8:18





Well if you remove the label then If Cells(i, 1) = Label4.Caption Then becomes nonsense as there is no label to refer to

– Tim Stack
Mar 28 at 8:18













So will be work like this? For i = 2 To Range("A10000").End(xlUp).Row If Cells(i, 1) = TextBox1.Text Then Cells(i, 2) = TextBox2.Text Cells(i, 3) = TextBox3.Text End If Next i

– orange
Mar 28 at 9:38





So will be work like this? For i = 2 To Range("A10000").End(xlUp).Row If Cells(i, 1) = TextBox1.Text Then Cells(i, 2) = TextBox2.Text Cells(i, 3) = TextBox3.Text End If Next i

– orange
Mar 28 at 9:38




1




1





Are you sure you are referring to the correct textbox? Use F8 to step through the code to see what values you are comparing with

– Tim Stack
Mar 28 at 9:44





Are you sure you are referring to the correct textbox? Use F8 to step through the code to see what values you are comparing with

– Tim Stack
Mar 28 at 9:44












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55392660%2fexcel-vba-userform-that-updates-an-selected-row-on-an-listbox%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.




















draft saved

draft discarded















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid …


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55392660%2fexcel-vba-userform-that-updates-an-selected-row-on-an-listbox%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?