+ Reply to Thread
Results 1 to 2 of 2

Problem using a macro from one workbook for a smilar purpose in another workbook

  1. #1
    Registered User
    Join Date
    07-24-2013
    Location
    Boston, MA
    MS-Off Ver
    Excel 2010
    Posts
    32

    Problem using a macro from one workbook for a smilar purpose in another workbook

    Hello. A few days ago, someone assisted me in creating a macro that enabled me to copy certain cells from one sheet to another when a check box was ticked. Works like a charm.

    I have another workbook where I want to do something similar. I thought I could easily substitute spreadsheet names and cell ranges to make the same macro work here. But I've not been successful. Attached is a shell of the workbook I'm working on now. Check boxes are there. This time I have several sheets and want specific cells from any checked rows on any of the sheets to move to the "programs requested" sheet at the end. I tried doing it with the first sheet (Brockton) as a test and had no luck. Here is the language below....Getting run time errors, among others. FYI, the cells I would like moved over when checked are A,B,D,N,P,R and S.

    Could someone assist me?
    Thank you!


    Sub Brock()
    Dim rng As Range
    Dim crng As Range

    Set crng = Sheets("Brockton").Range("T3:T21")

    For Each cell In crng
    Set rng = Sheets("Programs requested").Range("A1").End(xlDown).Offset(1, 0)
    If cell.Value = True And Application.CountIf(Sheets("Brockton").Range("A:A"), cell.Offset(0, -7).Value) = 0 Then
    rng.Value = cell.Offset(0, -7)
    rng.Offset(0, 1).Value = cell.Offset(0, -6)
    rng.Offset(0, 2).Value = cell.Offset(0, -5)
    rng.Offset(0, 3).Value = cell.Offset(0, -4)
    rng.Offset(0, 4).Value = cell.Offset(0, -3)
    End If

    Next cell

    End Sub
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,937

    Re: Problem using a macro from one workbook for a smilar purpose in another workbook

    Please Login or Register  to view this content.
    -------------------------------------------------------------------------------------
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    Ben Van Johnson

+ 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: 3
    Last Post: 05-05-2012, 11:43 AM
  2. Problem with add a sheet to workbook macro
    By westonkw in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-24-2009, 10:45 AM
  3. Problem with closing workbook in macro
    By slm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-10-2005, 09:05 PM
  4. Macro Name problem when I change workbook name?
    By Mike in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-26-2005, 10:06 AM
  5. Problem executing a macro from different workbook where it is
    By Sergio Calleja in forum Excel General
    Replies: 1
    Last Post: 01-17-2005, 09:06 AM

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