+ Reply to Thread
Results 1 to 3 of 3

VBA Update fields in different tabs button function

Hybrid View

BridgeCat VBA Update fields in... 10-20-2011, 05:01 AM
Kyle123 Re: VBA Update fields in... 10-20-2011, 05:45 AM
BridgeCat Re: VBA Update fields in... 10-20-2011, 06:11 AM
  1. #1
    Registered User
    Join Date
    04-24-2011
    Location
    Brisbane, QLD
    MS-Off Ver
    Excel 2002
    Posts
    25

    VBA Update fields in different tabs button function

    So I need to create a button that when pressed will update values in another sheet.

    Attached I have two sheet Order and Count. What I would like if possible is a button on the Order sheet that when pressed will find the matching supplier and product name in the Count sheet and replace the "purchase" value, with the "order value".

    Ie Supplier A, Product Pen, Size 1. When the button on Order sheet is pressed it would take the "purchase" value D3, and replace Counts "purchase" value F2 for that Supplier/Product/Size

    In the real table you need to search across supplier, pen & size to find a unique value.

    I would like it to Highlight the cell yellow after an update has been done so if the button is accidentally pressed you can flick over and just see any cells in yellow.

    I hope that makes sense. Not sure if it is possible as it is far over my head!

    Thanks
    Attached Files Attached Files
    Last edited by BridgeCat; 10-20-2011 at 06:11 AM.

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: VBA Update fields in different tabs button function

    I think I'd go for the below:

    Public Sub CopyData()
    Dim RowNumber As Long
    Dim columnNumber As Integer
    Dim sRng As Range
    
    Application.ScreenUpdating = False
    
    Sheets("Counts").AutoFilterMode = False
    
    With Sheets("Order")
        Set sRng = .Cells(1, 1).CurrentRegion.Offset(1, 0).Resize(.Cells(1, 1).CurrentRegion.Rows.Count - 1, 4)
    End With
    
    With sRng
        For RowNumber = 2 To .Rows.Count
            For columnNumber = 1 To 3
                Sheets("Counts").Cells(1, 1).CurrentRegion.AutoFilter _
                    Field:=columnNumber, Criteria1:="=" & .Cells(RowNumber, columnNumber).Value
            Next columnNumber
            With Sheets("Counts").UsedRange.SpecialCells(xlCellTypeVisible)
                .Cells(.End(xlDown).Row, 6).Value = sRng.Cells(RowNumber, 4).Value
                .Cells(.End(xlDown).Row, 6).Interior.Color = vbYellow
            End With
        Next RowNumber
    End With
    
    
    Sheets("Counts").AutoFilterMode = False
    
    Application.ScreenUpdating = True
    
    End Sub

  3. #3
    Registered User
    Join Date
    04-24-2011
    Location
    Brisbane, QLD
    MS-Off Ver
    Excel 2002
    Posts
    25

    Re: VBA Update fields in different tabs button function

    Work perfectly thanks heaps!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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