Results 1 to 3 of 3

vba code from closed workbook to update active sheet not working as requested

Threaded View

JEAN1972 vba code from closed workbook... 10-22-2017, 08:34 AM
jindon Re: vba code from closed... 10-22-2017, 08:44 AM
JEAN1972 Re: vba code from closed... 10-22-2017, 09:35 AM
  1. #1
    Forum Contributor
    Join Date
    02-11-2014
    Location
    mauritius
    MS-Off Ver
    MS365
    Posts
    1,142

    vba code from closed workbook to update active sheet not working as requested

    I have a database workbook on C:\Users\user\documents which is always close.

    The active sheet has the following code to update column C and D of invoice workbook which is the active sheet.

    But on trigger , I am getting an open dialog box with update values looking for the file , each time I pressed the cancel key of dialog box, it updates one cell , the dialog box open , press cancel it update one cell by one cell.

    Can anyone assist


    
    Sub JEANtest()
    Dim i As Long, ws As Worksheet, y
    Set ws = ActiveSheet
    With ws
    ReDim y(2 To .Range("B" & Rows.Count).End(3).Row)
    For i = LBound(y) To UBound(y)
        .Cells(i, "C").Formula = "=VLOOKUP(B" & i & ",'C:\Users\user\Documents\[database.xlsx]data BASE'!$B$2:$D$13,2,FALSE)"
        .Cells(i, "D").Formula = "=VLOOKUP(B" & i & ",'C:\Users\user\[database.xlsx]data BASE'!$B$2:$D$13,3,FALSE)"
        .Cells(i, "C").Resize(, 2).Value = .Cells(i, "C").Resize(, 2).Value
    Next i
    End With
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] macro to copy specifc sheet in closed workbook to the active sheet
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-07-2017, 09:53 AM
  2. [SOLVED] macro to copy active sheet to a closed workbook in a specified directory
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-30-2017, 04:43 AM
  3. [SOLVED] vba copy specific sheet from closed workbook to active workbook
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-12-2017, 01:33 PM
  4. [SOLVED] copy specific sheet from closed workbook to active workbook
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-10-2017, 10:26 PM
  5. vba copy specific sheet from closed workbook to active workbook
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-09-2017, 02:34 PM
  6. VBA to import all sheets from closed workbook to Active Sheet.
    By shiva_reshs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-20-2014, 02:42 PM
  7. [SOLVED] Code to copy data from a closed workbook and paste in active workbook using named range.
    By paullie1912 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-28-2014, 02:38 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1