Automatization based on cells

Eziooh

New Member
Joined
Apr 1, 2019
Messages
17
Hello, I have 3 tables and I need to get a register from table 1 to table 3 based on a choose on table 2. I need to get it automatized.
This is my code at the moment.
I hope you guys can help me.

Code:
Option Compare Text
Dim espaco As Range 'You can use this variable to get the range from row 7


Sub search()


Dim lastrow As Long
Dim Cell, cRange As Range
Dim value, result As String
valor = Worksheets("Table1").Range("D7").Value ' I need this to be a variable on row 7
lastrow = Sheets("Table3").Cells(Rows.Count, 4).End(xlUp).Offset(1).Row


' Range to see
    Set cRange = Worksheets("Artigos").Range("A1:B1000")
' For which cell in range
        For Each Cell In cRange


            If Cell.Value = valor Then


              resultado = Cell.Offset(0, -1).Value
             'Range("D" & Rows.Count).End(xlUp).Offset(1, 4).Select
            'ActiveCell.End(xlDown).Offset(3, 4).Select
            'ActiveCell.Value = resultado
            Sheets("Table3").Cells(lastrow, 4) = resultado
End If
' Check next cell in range
        Next Cell


End Sub

****** id="cke_pastebin" style="position: absolute; top: 56px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">Option Compare Text
Dim espaco As Range


Sub search()


Dim lastrow As Long
Dim Cell, cRange As Range
Dim value, result As String
valor = Worksheets("Table1").Range("D7").Value ' I need this to be a variable on row 7
lastrow = Sheets("Table3").Cells(Rows.Count, 4).End(xlUp).Offset(1).Row


' Range to see
Set cRange = Worksheets("Artigos").Range("A1:B1000")
' For which cell in range
For Each Cell In cRange


If Cell.Value = valor Then


resultado = Cell.Offset(0, -1).Value
'Range("D" & Rows.Count).End(xlUp).Offset(1, 4).Select
'ActiveCell.End(xlDown).Offset(3, 4).Select
'ActiveCell.Value = resultado
Sheets("Table3").Cells(lastrow, 4) = resultado
End If
' Check next cell in range
Next Cell


End Sub



 
Which line of code is highlighted when you click "Debug"? Please post your revised code that is giving you the error.


Code:
 Set fnd = Sheets("Artigos").Range("A:B300").Find(Target.Value, LookIn:=xlValues, lookat:=xlWhole) 'There are the interval values, it searches on B and gives me A
 
Upvote 0

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
The macro I suggested did not take column B into account. Please explain in detail what you mean by
There are the interval values, it searches on B and gives me A
I think that it would be easier to help and test possible solutions if I could work with your actual file which includes any macros you are currently using. Perhaps you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Include a detailed explanation of what you would like to do using a few examples from your data and referring to specific cells, rows, columns and worksheets. If the workbook contains confidential information, you could replace it with generic data.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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