read what I wanna do and answer to me if you can help

Lottoguy

New Member
Joined
May 27, 2016
Messages
42
I work on excel mostly for my lottery analysis, and as I develop some different types of analysis I end up having
to do all the work manually because I m not sure if I can automate it. To save me time and all the work of doing it manually, I d like to find out how excel can do it
automatically. What I do, I work with two tables on the same sheet, one if table A and the other is table B. Both are beside each other just separated by a blank column between them. Both tables has the same number of rows and columns, but different numbers on them. What I do, I highlight the numbers I m searching on table A, but what I need is to look up and write down on a piece of paper the numbers of the same cell of table B that are occupying the same position of the table A. Like on the same row and the same position of the column of the table A. I cant highlight just the numbers of one table, but I d like to find out how to program the excel to highlight the correspondent cell of the other table, then to paste those numbers on a different range of the same sheet or at another sheet. doing it manually, looking up, writing down on a piece of paper and then typing them again on another sheet is ok when we dont have so many numbers, but it can take a lot of time if I want to do it with a lot of numbers. If you can help let me know if I need a macro to do it.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
I find your explanation to be a bit confusing, but then again I have always been a very visual person. I think what may be most helpful to people here is if you could show an example of your data AND your expected results.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Its very easy to understand if you see it. I can show ya a video. What I need to go is to get the numbers pasted of the table B that are on the same positions of the highlighted numbers of table A. I can highlight the numbers of one table at a time, but I want the numbers of the other table. Like if the number of the A1 cell is highlighted, then I want the number on H1 pasted on another part of the sheet. its 6 columns on table A, a-b-c-d-e-f and on table B is h-i-j-k-l-m columns. Can you figure out what I wanna do or do I need to make a video explaning it?
 
Upvote 0
Paste the following into a Regular module :

VBA Code:
Option Explicit

Sub SelectNumbs()
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Sheets(1) ' Adjust to your sheet name if different
    
    Dim lastRow As Long
    lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row ' Dynamically get the last row for range A1:F
    
    Dim rng1 As Range
    Set rng1 = ws.Range("A1:F" & lastRow)
    
    Dim rng2 As Range
    Set rng2 = ws.Range("H1:M" & lastRow)
    
    Dim targetCell As Range
    Set targetCell = ws.Range("O" & ws.Cells(ws.Rows.Count, "O").End(xlUp).Row + 1)
    
    Dim selectedCell As Range
    Set selectedCell = ActiveCell
    
    If Not Intersect(selectedCell, rng1) Is Nothing Then
        Dim number1 As String
        number1 = selectedCell.Value
        
        Dim rowOffset As Long
        rowOffset = selectedCell.Row - rng1.Rows(1).Row
        
        Dim colOffset As Long
        colOffset = selectedCell.Column - rng1.Columns(1).Column
        
        Dim number2 As String
        number2 = rng2.Cells(1 + rowOffset, 1 + colOffset).Value
        
        targetCell.Value = number1 & ":" & number2
        targetCell.Value = Replace(targetCell.Value, ":00", "")
    Else
        MsgBox "Please select a cell within the range A1:F" & lastRow
    End If
End Sub

Format Column O as : [h]:mm

The user is restricted to first select a number from Matrix One. Then click the command button. First clicking any other cell
located in any location other than Matrix One will result in an error.

For a larger range of Matrix One you need to edit the macro code.
The same thing applies to Column O. If you wish to use a different column for your resultant numbers you will need to edit the
macro as such and Custom Format that new column as [h]:mm
 
Upvote 0

Forum statistics

Threads
1,225,638
Messages
6,186,138
Members
453,339
Latest member
Stu61

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