Find value from active sheet and copy to another sheet

simke

New Member
Joined
Sep 19, 2022
Messages
5
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Dear sirs,

How can I use VBA to find first value in activesheet in column R. Value to search is written in sheet "Parameters" cell J5. Once it find first searched value, it gives value to left in column "O" and write this value to sheet "Parameters" to cell J6.

In this example(shown picture) it search value PN23-6 and it gives value 2000 to sheet "Parameters" in cell J6

Thank you for your help
 

Attachments

  • Test01.jpg
    Test01.jpg
    90.9 KB · Views: 7

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
If everything is to be dynamic, you have to explain where the value to put in O comes from or how it is determined to be 2000. Otherwise the solution you get would only put 2000 in column O which might be what you want?
 
Upvote 0
If everything is to be dynamic, you have to explain where the value to put in O comes from or how it is determined to be 2000. Otherwise the solution you get would only put 2000 in column O which might be what you want?
Sory if I wasn't clear.

Tha value in column O is static and it is already in the table. Idea is that makro search in active sheet first finded value PN23-6 and return value in the column O which is at the same row where is PN23-6.
 
Upvote 0
Maybe
VBA Code:
Sub simke()
Dim rng As range
Dim varValue As Variant

varValue = Sheets("Parameters").range("J5")
Set rng = ActiveSheet.rng.Find(What:=varValue, LookIn:=xlFormulas, MatchCase:=False, SearchFormat:=False)
If Not rng Is Nothing Then
   rng.Offset(0, -3) = 2000
End If

Set rng = Nothing
End Sub

EDIT - untested and probably not quite right. Search needs to be restricted to column R?
 
Last edited:
Upvote 0
For looking in R of active sheet
VBA Code:
Sub simke()
Dim rng As range
Dim varValue As Variant

varValue = Sheets("Parameters").range("J5")
Set rng = ActiveSheet.range("R:R").Find(What:=varValue, LookIn:=xlFormulas, MatchCase:=False, SearchFormat:=False)
If Not rng Is Nothing Then
   rng.Offset(0, -3) = 2000
End If

End Sub
 
Upvote 0
For looking in R of active sheet
VBA Code:
Sub simke()
Dim rng As range
Dim varValue As Variant

varValue = Sheets("Parameters").range("J5")
Set rng = ActiveSheet.range("R:R").Find(What:=varValue, LookIn:=xlFormulas, MatchCase:=False, SearchFormat:=False)
If Not rng Is Nothing Then
   rng.Offset(0, -3) = 2000
End If

End Sub
Hi Micron,

This is it what I need.

Thanks for your help
 
Upvote 0

Forum statistics

Threads
1,216,303
Messages
6,129,983
Members
449,549
Latest member
birdguy_1930

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