Filtered Row and Input box

gnissen

New Member
Joined
Jun 27, 2024
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Hi All, this is my first time using this, i hope someone can help.

I am filtering data using the following code
Dim sh As Worksheet
Set sh = ActiveSheet
sh.Unprotect "121"
sh.Range("B7:B2000").AutoFilter Field:=1, Criteria1:="=*" & InputBox("Reset Sheet", "Part Number Search", "*")
This will filter all my records and give me a single line of data, on row 7 "Perfect"

The problem is when i filter the data it filters the top rows so the data could be on row 7 or row 5o.

I then need to add a second input box in to allow the user to enter a value using the following code
myVal = InputBox("Enter New Count")
Range("H7").Value = myVal

BUT this is the trick, how do i enter the new value on the filtered line when the filtered line could now be "H50" or "Hxxxxx"
Regards
Greg
 

Attachments

  • Screenshot 2024-06-28 071008.png
    Screenshot 2024-06-28 071008.png
    24.1 KB · Views: 22

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
VBA Code:
sh.Range("H" & sh.Range("B8:B2000").SpecialCells(xlCellTypeVisible).Row).Value = MyVal
 
Upvote 0
sh.Range("H" & sh.Range("B8:B2000").SpecialCells(xlCellTypeVisible).Row).Value = MyVal
Hi and thank you, can you please confirm the code as it did not ask me for the part number first. or have i added it to the wrong place?

Dim newval As Variant
Dim sh As Worksheet
Set sh = ActiveSheet
sh.Unprotect "121"

Original code 'sh.Range("D6:D2000").AutoFilter Field:=1, Criteria1:=InputBox("Please Enter a Part# ", "Part Number Search")
Your code should i replace this with yours? sh.Range("H" & sh.Range("B8:B2000").SpecialCells(xlCellTypeVisible).Row).Value = myVal

'Application.GoTo Range("H7").SpecialCells(xlCellTypeVisible).Cells(1)

myVal = InputBox("Enter New Count")
Range("H7").Value = myVal


Regards
Greg
 
Upvote 0
VBA Code:
Dim newval As Variant
Dim sh As Worksheet
Set sh = ActiveSheet
sh.Unprotect "121"

sh.Range("D6:D2000").AutoFilter Field:=1, Criteria1:=InputBox("Please Enter a Part# ", "Part Number Search")

myVal = InputBox("Enter New Count")
sh.Range("H" & sh.Range("D7:D2000").SpecialCells(xlCellTypeVisible).Row).Value = myVal
 
Upvote 0
Dim newval As Variant Dim sh As Worksheet Set sh = ActiveSheet sh.Unprotect "121" sh.Range("D6:D2000").AutoFilter Field:=1, Criteria1:=InputBox("Please Enter a Part# ", "Part Number Search") myVal = InputBox("Enter New Count") sh.Range("H" & sh.Range("D7:D2000").SpecialCells(xlCellTypeVisible).Row).Value = myVal
It works perfect
Many Thanks for your help
Greg
 
Upvote 0
It works perfect
Many Thanks for your help
Greg
could i impose and ask if you could help with another thing.
Once the new value has been entered i need take column "I" being the new total from that row and move it to "G" and delete "H"
this will give me a previous count +the new count and delete "H" ready for a new value
 

Attachments

  • Screenshot 2.png
    Screenshot 2.png
    2.3 KB · Views: 14
Upvote 0
Why not have the macro just add myVal to "G"?

This adds myVal directly to G
VBA Code:
myVal = InputBox("Enter New Count")
with sh.Range("G" & sh.Range("D7:D2000").SpecialCells(xlCellTypeVisible).Row)
    .Value = .Value + myVal
End With
 
Upvote 0
Solution
Why not have the macro just add myVal to "G"?

This adds myVal directly to G
VBA Code:
myVal = InputBox("Enter New Count")
with sh.Range("G" & sh.Range("D7:D2000").SpecialCells(xlCellTypeVisible).Row)
    .Value = .Value + myVal
End With
Hi the idea was to have the the prev count "G" plus the new count "H" then "I" will be the total of the two. Then I will copy "I" to prev "G" Then delete "H". This will give me a new prev so I can repeat the process if multiple items are scanned.
 
Upvote 0
Hi the idea was to have the the prev count "G" plus the new count "H" then "I" will be the total of the two. Then I will copy "I" to prev "G" Then delete "H". This will give me a new prev so I can repeat the process if multiple items are scanned.
Thank you vey much, its all working perfect now
Many Many Thanks
Greg
 
Upvote 0
Thank you vey much, its all working perfect now
Many Many Thanks
Greg

The marked solution has been changed accordingly. In your future questions, please mark the post as the solution that actually answered your question, instead of your feedback message as it will help future readers. No further action is required for this thread.
 
Upvote 0

Forum statistics

Threads
1,224,811
Messages
6,181,081
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top