Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7777353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:07:15+00:00 2026-06-01T18:07:15+00:00

I have 2 Excel 2007 Worksheets. Excel Worksheet 1 : (as below ) 3

  • 0

I have 2 Excel 2007 Worksheets.

Excel Worksheet 1 : (as below ) 3 Columns are important in Sheet 1

userid   name   email

100      sam    sam@sam.com
200      pete   pete@pete.com
300      Bum    Bum@Bum.com 
400      Harry  Harry@Harry.com

Worksheet 2 : (as below) ( user_id column is empty for all )

userid   name   email

         sam    sam@sam.com
         Harry  Harry@Harry.com 
         pete   pete@pete.com
         Bum    Bum@Bum.com 

I need a function/forumla with a macro where i can fill the values for userid in sheet 2
where the sheet2 email = sheet1 email

which will result as following in worksheet 2

userid   name   email

100      sam    sam@sam.com
400      Harry  Harry@Harry.com 
200      pete   pete@pete.com
300      Bum    Bum@Bum.com 

I know SQL but the query takes a long long time on MySQL DB to get the result…
Anyways below is the SQL query i was using in the DB.

UPDATE  `j_A` 
SET user_id =   ( SELECT j_B.id
FROM j_B
WHERE j_B.email =  j_A.email)
WHERE EXISTS
  ( SELECT j_B.id
    FROM j_B
    WHERE j_B.email =  j_A.email);

Need Macro/Function/formula to Replace the Values of one Excel Sheet if both Email(Column) value matches,, if anyone cud help me regarding this creating Macro/Formula/functin etc…since
dont have much knowldge of creating formulae in Excel Macros..

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T18:07:17+00:00Added an answer on June 1, 2026 at 6:07 pm

    As per your example, try:

    Sub HTH
        With Sheet2.Range("A2:A" & Sheet2.Cells(Rows.Count, 2).End(xlUp).Row)
            .Formula = Replace("=LOOKUP(2,1/(Sheet1!C$2:C$x=C2)/(Sheet1!B$2:B$x=B2),Sheet1!A$2:A$x)", _
                "x", (Sheet1.UsedRange.Rows.Count - 1))
            .Value = .Value
        End With
    End Sub
    

    It will probably be more efficient to update the SQL query.

    To open the VBA editor press Alt-F11.

    Here is a screenshot of the code in the VBA editor with the code sample, click the green play button to run the code:

    enter image description here

    Based on the additional info you may want to try this alternative procdure:

    Sub HTH2()
        Dim vSource As Variant
        Dim vOutput As Variant
        Dim sKey As String
    
        vSource = Sheet1.UsedRange.Resize(, 3).Value
        vOutput = Sheet2.UsedRange.Resize(, 3).Value
    
        With CreateObject("Scripting.Dictionary")
            For lloop = 1 To UBound(vSource, 1)
                .Add vSource(lloop, 2) & ":" & vSource(lloop, 3), vSource(lloop, 1)
            Next lloop
    
            For lloop = 1 To UBound(vOutput, 1)
                sKey = vOutput(lloop, 2) & ":" & vOutput(lloop, 3)
                If .exists(sKey) Then
                    vOutput(lloop, 1) = .Item(sKey)
                Else
                    vOutput(lloop, 1) = ""
                End If
            Next lloop
        End With
    
        Sheet2.Range("A1").Resize(UBound(vOutput, 1), 1).Value = vOutput
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Excel 2007 and Windows XP When this code runs: Columns(A:G).Select ActiveWorkbook.Worksheets(Sheet1).Sort.SortFields.Clear ActiveWorkbook.Worksheets(Sheet1).Sort.SortFields.Add
I have an Excel spreadsheed like the one shown below A B 10.02.2007 10
Using Excel 2007 VBA Have a sheet Dashboard, have other sheets but some special
I have an excel 2007 worksheet open with 5 colums and +/-5000 rows of
i have a c# code which gets the (excel-2007) worksheets used range as follows
I have a web page which links to an Excel 2007 worksheet. It is
I am working on an worksheet generator in Excel 2007. I have a certain
Using Windows XP and Excel 2007 I have a worksheet with a macro in
I have an Excel 2007 ODBC connection defined and I need to allow users
I have problem creating new instance of excel 2007 using VBA (from Access 2002).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.