+ Reply to Thread
Results 1 to 4 of 4

Automatically fill in data table with values from navigator

  1. #1
    Registered User
    Join Date
    11-27-2011
    Location
    São Paulo, Brazil
    MS-Off Ver
    Excel 2007
    Posts
    2

    Automatically fill in data table with values from navigator

    Hello,

    I have a data table of large size in one sheet and i created a simple navigator to pull info from it on another sheet.

    The user uses the navigator and may change some values in order to run some simulations. If the values he changed satisfy him, he should be able to save them in the original data table for future reference.

    In the table i have a row key that identifies the rows where the value should be changed and the column, is constant.

    I do not know how to create a macro that will search all the rows that match the key and change the values of a certain column. I could make a macro that filters the table to match the key and then changes the visible values but im sure there must be a better way.

    Can anyone help me with this problem?

  2. #2
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Automatically fill in data table with values from navigator

    Pl attach a mock workbook.

  3. #3
    Registered User
    Join Date
    11-27-2011
    Location
    São Paulo, Brazil
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Automatically fill in data table with values from navigator

    OK So I have managed to make it work...mostly need some help with this last part..

    Atualizar_canal should read all the values of one row and copy them to the database following the rules in SearchAndReplace2...the code works for the first value of the first column of the row but it then sends a type mistmatch error before saving the other columns....im guessing my problem is in the FOR loop that saves the column values and then calls the SearchAndReplace2 function

    Any ideas?



    Sub Atualizar_canal()
    '
    ' Atualizar_canal Macro
    Dim Region, SKU
    Dim KeyC(11) As String
    Dim DChan(11) As Double
    Region = Cells(4, 3).Value
    SKU = Cells(5, 3).Value

    Answer = MsgBox("Deseja alterar a política de canais ?", vbOKCancel, "Política da Região")
    If Answer = Cancel Then Exit Sub Else
    For CCount = 1 To 11
    KeyC(CCount) = Region & Cells(7, CCount + 3) & SKU
    DChan(CCount) = Cells(22, CCount + 3).Value
    Call SearchAndReplace2(KeyC(CCount), DChan(CCount))
    Sheets(2).Cells(22, CCount + 3).Value = 0
    Next CCount

    End Sub

    Sub SearchAndReplace2(ByVal KeyC As String, ByVal DChan As Double)

    For lCount = 1 To 65536
    If Sheets(3).Cells(lCount, 2).Value = KeyC Then
    Sheets(3).Cells(lCount, 31) = Sheets(3).Cells(lCount, 31).Value - DChan
    End If
    Next lCount

    End Sub

  4. #4
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Automatically fill in data table with values from navigator

    Please edit your post to add code tags per the Forum Rules.

    Here's how:

    [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code]
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

+ 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