+ Reply to Thread
Results 1 to 3 of 3

Adjust a macro to check for content of a cell and then run a macro on target sheet

  1. #1
    Forum Contributor
    Join Date
    03-18-2013
    Location
    Bulgaria
    MS-Off Ver
    Excel 2010
    Posts
    139

    Adjust a macro to check for content of a cell and then run a macro on target sheet

    Hey guys,

    I need help with adjusting my macro. Basically it opens a file and then copies content. However before doing the copying, I want it to check if on the file it opened whether the content of G1 is "pass". If it is pass to run the macro "Adjust" on that workbook.

    How do I do that? I tried with:
    If ActiveWorkbook.Worksheets("Target").Cell("G1") = "pass" Then Application.Run ActiveWorkbook.Name & "!Adjust"
    but it gives me an error

    Please Login or Register  to view this content.
    Thank you in advance!

    P.S.:
    Okay, found it. It works fine this way:
    If ActiveWorkbook.Worksheets("Target").Range("G1").Value = "pass" Then Application.Run ActiveWorkbook.Name & "!Adjust"
    Last edited by dreddster; 10-17-2013 at 07:24 AM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Adjust a macro to check for content of a cell and then run a macro on target sheet

    Is this solved?

    If you solve a problem yourself before anyone else has responded, please take a moment to describe your solution, chances are some other member will benefit.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Contributor
    Join Date
    03-18-2013
    Location
    Bulgaria
    MS-Off Ver
    Excel 2010
    Posts
    139

    Re: Adjust a macro to check for content of a cell and then run a macro on target sheet

    Thank you Arlu, I updated it. However, it seems I have another issue.

    When there is a dash (-) in the name of the secondary file, the macro won't start and gives error 1004. When I remove the dash from the file name, it works fine.

    What is the problem with the dash and any ideas how to solve this?

    P.S.:
    Found it, when you put it like that it works fine
    If ActiveWorkbook.Worksheets("Target").Range("G1").Value = "endprint" Then Application.Run "'" & ActiveWorkbook.Name & "'!Adjust"
    Last edited by dreddster; 10-17-2013 at 07:23 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 10-28-2012, 01:13 AM
  2. Adding Dynamic Comments based on the Target Cell Content..using a MACRO..
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-20-2012, 04:14 AM
  3. Replies: 1
    Last Post: 02-19-2007, 04:52 PM
  4. Replies: 3
    Last Post: 11-18-2005, 05:00 PM
  5. How to check a cell for content before running macro.
    By Incoherent in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-07-2005, 12:05 PM

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