+ Reply to Thread
Results 1 to 8 of 8

Macro Code Should Change When entered Cell Value matched????

  1. #1
    Registered User
    Join Date
    07-01-2013
    Location
    mumbai
    MS-Off Ver
    Excel 2003
    Posts
    43

    Macro Code Should Change When entered Cell Value matched????

    Hi,

    Could you please me this logic,

    In particular Cell, the value is entered, That value should be replace in VB macro code in particular line.

    Example:

    In sheet = C5 cell have "Submit"

    in VB Macro code, In 5th line, "Start" code available, so now i need to replace the START to SUBMIT in vb macro.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Macro Code Should Change When entered Cell Value matched????

    Why do you need to change the code?
    If posting code please use code tags, see here.

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro Code Should Change When entered Cell Value matched????

    Hello amiable,

    It would be a great help if we could see your actual Code where you want to make the change.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  4. #4
    Registered User
    Join Date
    07-01-2013
    Location
    mumbai
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Macro Code Should Change When entered Cell Value matched????

    Am using different file name, so when am running the file, i need to change the file name from macro, so instead ed of go to edit->vb macro, If possible,in work only, if i enter the data, after that data will replace the code in particular line. If third person whats to run the code, just give the file name and use the short cut key to run the code.
    So no need to go and modify the code.

  5. #5
    Registered User
    Join Date
    07-01-2013
    Location
    mumbai
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Macro Code Should Change When entered Cell Value matched????

    Worksheets("602.vb").Activate
    While end_process = False
    On Error GoTo nxt
    Cells.Find(What:=Sheet13.Cells(a, 1), After:=Sheet7.Cells(1, 1), LookIn:=xlFormulas, LookAt:= _
    xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=True _
    , SearchFormat:=False).Activate

    This is sample code.
    So i need to change the 602.VB name every time when am running thedifferent vb code and SHEET 7 also i need to change, SHEET7 is replacing the all value.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Macro Code Should Change When entered Cell Value matched????

    You don't need to change the code for that.

    Read the value from the cell and then use that to identify the right worksheet.

    Please Login or Register  to view this content.
    PS When posting use code tags - it's kind of a forum rule.

  7. #7
    Registered User
    Join Date
    07-01-2013
    Location
    mumbai
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Macro Code Should Change When entered Cell Value matched????

    Hi Norie,

    I am facing Error 91, Subscript out of range, This is my code, I have updated the your code also.
    In G5 Cell, I am giving the file name. In ws variable cell value is not assign. pls find the attachment

    Please help this issue.

    PHP Code: 
    Sub Windows()

    Dim ws As Worksheet
    Dim rngFnd 
    As Worksheet
    Dim strSheet 
    As String

    end_process 
    False
    1

    strSheet 
    Sheet1.Cells.Range("G5")

    Set ws Worksheets("strSheet").Activate


    While end_process False
         On Error 
    GoTo nxt
        Cells
    .Find(What:=Sheet1.Cells(a1), After:=ws.Cells(11), LookIn:=xlFormulasLookAt:= _
         xlPart
    SearchOrder:=xlByRowsSearchDirection:=xlNextMatchCase:=True _
        
    SearchFormat:=False).Activate
        
        sactrow 
    ActiveCell.Row
        sactcol 
    ActiveCell.Column
        cellcont 
    ActiveCell
        srchlen 
    Len(Sheet1.Cells(a2))
        
    end_require False
        
        
    While end_require False
            
    For 1 To Len(cellcont)
                If 
    Mid(cellcontxsrchlen) = Sheet1.Cells(a2Then 
                    pos 
    x
                    newstring1 
    Mid(cellcont1pos 1)
                    
    newstring2 Sheet1.Cells(a3)
                    
    newstring3 Mid(cellcontpos srchlenLen(cellcont) - (pos + (srchlen 1)))
                    
    ws.Cells(ActiveCell.RowActiveCell.Column) = newstring1 newstring2 newstring3
                    End 
    If
            
    Next x
            Cells
    .FindNext(After:=ActiveCell).Activate
            cellcont 
    ActiveCell
            
    If sactrow ActiveCell.Row And sactcol ActiveCell.Column Then
                end_require 
    True
            End 
    If
            
        
    Wend 
    Attached Files Attached Files
    Last edited by amiable; 07-11-2013 at 02:29 AM.

  8. #8
    Registered User
    Join Date
    07-01-2013
    Location
    mumbai
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Macro Code Should Change When entered Cell Value matched????

    Please help me????

+ 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