By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,214 Members | 2,066 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,214 IT Pros & Developers. It's quick & easy.

Enter data in Excel sheet by textbox through VB coding

P: 1
Hi dear friends.
Can anyone help me?
I created a VB form in Excel and a textbox and one command button. When I click the command button the text entered in the textbox will store in the empty cell range.
Of course it will show do.
But I like when I entered in the text in the textbox which already entered in the Excel sheet msgbox should show that the text already entered you cannot reenter and it should not enter the text again in sheet.
I hope that you can help me?
Sep 7 '07 #1
Share this Question
Share on Google+
2 Replies


kadghar
Expert 100+
P: 1,295
Im not quite sure i understood you, but i think this might be useful:

Expand|Select|Wrap|Line Numbers
  1. sub commandbutton1_click()
  2.  
  3. with worksheets(1).cells(1,1)
  4.     if .value<> "" then
  5.         .value = textbox1.text
  6.     else
  7.         msgbox("You cannot fill that cell twice")
  8.     end if
  9. end with
  10.  
  11. end sub
Hope that helps
Sep 7 '07 #2

QVeen72
Expert 100+
P: 1,445
Im not quite sure i understood you, but i think this might be useful:

Expand|Select|Wrap|Line Numbers
  1. sub commandbutton1_click()
  2.  
  3. with worksheets(1).cells(1,1)
  4.     if .value<> "" then
  5.         .value = textbox1.text
  6.     else
  7.         msgbox("You cannot fill that cell twice")
  8.     end if
  9. end with
  10.  
  11. end sub
Hope that helps
Hi Kadghar,

If condition should be Reversed:

Expand|Select|Wrap|Line Numbers
  1. sub commandbutton1_click()
  2.  
  3. with worksheets(1).cells(1,1)
  4.     if Trim(.value) =  "" then
  5.         .value = textbox1.text
  6.     else
  7.         msgbox("You cannot fill that cell twice")
  8.     end if
  9. end with
  10. end sub
  11.  
REgards
Veena
Sep 8 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.