ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Still stuck on macro... (https://www.excelbanter.com/excel-discussion-misc-queries/80094-still-stuck-macro.html)

chip_pyp

Still stuck on macro...
 
I got help in a previous post. instead of using a series of input boxes to
gather information i'm using a userform. so with this userform the user
inputs information into each given area adn then it inserts that inforation
into the next available row. however the user form has two tabs one to add
new information and one to alter information. on the alter tab the user puts
in a series of numbers and puts in information they want to change associated
with the number they put in. so the part i'm stuck in is when they click the
"alter" button i inserted i want the userform to search the spreadsheet for
that first number, once it finds it it inputs the new data in the appropriate
columns on that row next to the first column. so basically the macro
associated with this userform will find the first number inputed by the user
in the spreadsheet, once found it will change the information next to
it...any suggestions?

Dave Peterson

Still stuck on macro...
 
If I were using the code with inputboxes, this is how I'd use it:

Option Explicit

Public Sub getdata()
Dim nextrow As Long
Dim entry1 As String, entry2 As String, entry3 As String
Dim entry4 As String, entry5 As String
Dim res As Variant

Do

entry1 = InputBox("What is the HFC MAC?", "HFC")
If entry1 = "" Then Exit Sub

res = Application.Match(entry1, Range("a:a"), 0)

If IsError(res) Then
'not already in the list
nextrow = Range("A65536").End(xlUp).Row + 1
Else
nextrow = res
End If

entry2 = InputBox("What kind of modem is it?")
If entry2 = "" Then entry2 = Cells(nextrow - 1, 2).Value

entry3 = InputBox("Where is the modem? Default is 'Shelved'")
If entry3 = "" Then entry3 = "Shelved" '<--typo!

entry4 = InputBox("What's the status of the modem: Renting," _
& " Purchased or Pending. Default is 'Pending'")
If entry4 = "" Then entry4 = "Pending"

entry5 = InputBox("What is today's date?", Default:=Date)
If entry5 = "" Then entry5 = Cells(nextrow - 1, 5).Value

Cells(nextrow, 1) = entry1
Cells(nextrow, 2) = entry2
Cells(nextrow, 3) = entry3
Cells(nextrow, 4) = entry4
Cells(nextrow, 5) = entry5
Loop

End Sub

You can use application.match to see if the entry is there and to determine the
row where it resides.

Maybe you can include some of this stuff in your userform code.





chip_pyp wrote:

I got help in a previous post. instead of using a series of input boxes to
gather information i'm using a userform. so with this userform the user
inputs information into each given area adn then it inserts that inforation
into the next available row. however the user form has two tabs one to add
new information and one to alter information. on the alter tab the user puts
in a series of numbers and puts in information they want to change associated
with the number they put in. so the part i'm stuck in is when they click the
"alter" button i inserted i want the userform to search the spreadsheet for
that first number, once it finds it it inputs the new data in the appropriate
columns on that row next to the first column. so basically the macro
associated with this userform will find the first number inputed by the user
in the spreadsheet, once found it will change the information next to
it...any suggestions?


--

Dave Peterson

chip_pyp

Still stuck on macro...
 
Thank you very much Dave. You have been most helpful in many of my posts.
Thanks again!



All times are GMT +1. The time now is 04:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com