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

1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

인천여자상업고등학교 목차 학교 연혁 설치 학과 학교 동문 참고 자료 각주 외부 링크 둘러보기 메뉴북위 37° 28′ 05″ 동경 126° 37′ 41″ / 북위 37.4680025° 동경 126.6279602°  / 37.4680025; 126.6279602인천여자상업고등학교“인천광역시립학교 설치조례 별표1”인천여자상업고등학교 홈페이지eheh문서를 완성해