Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: write permanently to another sheet from a cell with formulated lookup value

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    10
    Rep Power
    0

    write permanently to another sheet from a cell with formulated lookup value

    D32 has the formula
    =IF(AND(VLOOKUP(J1,PMast!A8:CC5001,9,FALSE)="P",K2 2="NA"),"NA",IF(IF(AND(D30="NA",D31="NA"),"NA",IF( MAX(D30,D31)<4500,4500,MAX(D30,D31)))>17950,17950, IF(AND(D30="NA",D31="NA"),"NA",IF(MAX(D30,D31)<450 0,4500,MAX(D30,D31)))))

    D32 changes with the vlookup values entered therein
    what i need is

    each time when i enter a new lookupvalue i need the D32 to be
    copied/written permanently, in the BL column of corresponding row of vlookup value in the the sheet PMast

    that is
    if vlook up value is 1 and d32=2526 then in sheet PMast, BL1 = 2526

    & when i enter vlook up value 6 and d32=5255 then in sheet PMast, BL6= 5255 and BL1 = 2526

    again if i enter vlook up value is 1 and d32=3333(since i changed some other values) then in sheet PMast,
    BL1 = 3333 (re-written) and BL6=5255

  2. #2
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi Ajish,

    Put this code in Sheet module. Right click on your formula tab > View code and paste the code there.

    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
        
        If Target.Address(0, 0) <> "J1" Then Exit Sub
        
        If Len(Target) Then
            If IsNumeric(Target) Then
                With Worksheets("PMast").Range("BL:BL")
                    .Cells(Target.Value, 1) = Range("D32").Value
                End With
            End If
        End If
            
    End Sub
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  3. #3
    Junior Member
    Join Date
    Jul 2012
    Posts
    10
    Rep Power
    0
    Thanks in advance
    but the value is being pasted in the BL column 2nd row, if the vlookup value is given "2"
    the value need to be pasted in BLth column,but not in 2nd row if the vlookup value is "2",
    but corresponding lookup value is in the A column and if lookup value "2" is in A8 then D32 should be written in BL8

  4. #4
    Junior Member
    Join Date
    Jul 2012
    Posts
    10
    Rep Power
    0
    Thanks in advance
    but the value is being pasted in the BL column 2nd row, if the vlookup value is given "2"
    the value need to be pasted in BLth column,but not in 2nd row if the vlookup value is "2",
    but corresponding lookup value is in the A column and if lookup value "2" is in A8 then D32 should be written in BL8

  5. #5
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi Ajish,

    May be..

    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
        
        If Target.Address(0, 0) <> "J1" Then Exit Sub
        
        Dim LookupValueRow  As Variant
        
        If Len(Target) Then
            LookupValueRow = WorksheetFunction.Match(Target, Range("a:a"), 0)
            If Not IsError(LookupValueRow) Then
                Worksheets("PMast").Cells(LookupValueRow, "BL") = Range("D32").Value
            End If
        End If
            
    End Sub
    If this is not the case, attach a workbook with expected result.
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  6. #6
    Junior Member
    Join Date
    Jul 2012
    Posts
    10
    Rep Power
    0
    how can i attach a file here????

  7. #7
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Click on Go Advanced, and scroll down to find the attachment button
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  8. #8
    Junior Member
    Join Date
    Jul 2012
    Posts
    10
    Rep Power
    0

    write permanently to another sheet from a cell with formulated lookup value

    the code give works almost fine but doesnt actually write in the exact row of (lookup value columnA)
    here in sample sheet PMast is named as sheet2
    also note if there id no such value in column A for typed look up value it should not write any thing
    Attached Files Attached Files
    Last edited by ajish002; 08-18-2012 at 10:09 PM.

  9. #9
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi

    Try

    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
        
        If Target.Address(0, 0) <> "J1" Then Exit Sub
        
        Dim LookupValueRow  As Variant
        
        Const DestSheet     As String = "Sheet2"    '<<<<< adjust to suit
        Const ColA_StartRow As Long = 5             '<<<<< adjust to suit
        
        If Len(Target) Then
            LookupValueRow = WorksheetFunction.Match(Target, Range("a:a"), 0)
            If Not IsError(LookupValueRow) Then
                Worksheets(DestSheet).Cells(LookupValueRow - ColA_StartRow + 1, "BL") = Range("D32").Value
            End If
        End If
            
    End Sub
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  10. #10
    Junior Member
    Join Date
    Jul 2012
    Posts
    10
    Rep Power
    0
    Quote Originally Posted by Admin View Post
    Hi

    Try

    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
        
        If Target.Address(0, 0) <> "J1" Then Exit Sub
        
        Dim LookupValueRow  As Variant
        
        Const DestSheet     As String = "Sheet2"    '<<<<< adjust to suit
        Const ColA_StartRow As Long = 5             '<<<<< adjust to suit
        
        If Len(Target) Then
            LookupValueRow = WorksheetFunction.Match(Target, Range("a:a"), 0)
            If Not IsError(LookupValueRow) Then
                Worksheets(DestSheet).Cells(LookupValueRow - ColA_StartRow + 1, "BL") = Range("D32").Value
            End If
        End If
            
    End Sub
    again it writes in sheet2 column BL 2nd row(BL2) when lookupvalue (ie J1) is given "2"
    but since "2"(J1) is in columnA row3 in sheet2 output should be in BL3
    Last edited by ajish002; 08-19-2012 at 12:29 PM.

Similar Threads

  1. Replies: 2
    Last Post: 03-21-2013, 10:38 PM
  2. Lookup From Cell Range By Matching Row and Column
    By paul_pearson in forum Excel Help
    Replies: 2
    Last Post: 03-07-2013, 02:02 PM
  3. Replies: 1
    Last Post: 02-10-2013, 06:21 PM
  4. Concatenate Multiple Lookup Values in Single Cell
    By Admin in forum Download Center
    Replies: 4
    Last Post: 04-06-2012, 09:07 PM
  5. Split Cell and Lookup
    By bsiq in forum Excel Help
    Replies: 4
    Last Post: 11-21-2011, 10:03 PM

Posting Permissions

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