+ Reply to Thread
Results 1 to 3 of 3

Excel formula wont work

  1. #1
    Registered User
    Join Date
    07-03-2007
    Posts
    3

    Excel formula wont work

    Hi In a macro i am using the same formula in 2 columns at one it works and in the other it does not work. Not sure whats going on any help?

    I have attached the sample file herewith.

    Here is the macro code

    Any help is appreciated. Cheers

    ___________________________________________________________________________
    Sub RunCodeOnAllXLSFiles()

    Dim Sht As Worksheet
    Dim Name1 As String

    Name1 = ThisWorkbook.Name



    For Each Sht In ActiveWorkbook.Worksheets

    Sht.Activate
    Columns("B:B").Select
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("B1").Select
    ActiveCell.FormulaR1C1 = "=IF(LEN(RC[-1])>0,""%%%%%"","""")"
    Range("B1").Select
    Selection.Copy
    Range("B1:B500").Select
    ActiveSheet.Paste

    Range("D1").Select
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = "=IF(LEN(RC[-1])>0,""$$$$$"","""")"
    Range("D1").Select
    Selection.Copy
    Range("D1:D500").Select
    ActiveSheet.Paste

    Next Sht



    For Each Sht In ActiveWorkbook.Worksheets

    Sht.Activate
    '
    ChDir "C:\Men"
    ActiveWorkbook.SaveAs Filename:= _
    "C:\Men\" & Name1 & "_" & Sht.Name & ".txt" _
    , FileFormat:=xlTextMSDOS, CreateBackup:=False
    Next Sht
    End Sub
    ______________________________________________________________________
    Attached Files Attached Files
    Last edited by thepitzaboy; 07-07-2011 at 07:17 PM. Reason: Forget quote tag

  2. #2
    Valued Forum Contributor
    Join Date
    07-17-2005
    Location
    Abergavenny, Wales, UK
    MS-Off Ver
    XL2003, XL2007, XL2010, XL2013, XL2016
    Posts
    608

    Re: Excel formula wont work

    Hi

    Maybe

    Please Login or Register  to view this content.
    --
    Regards
    Roger Govier
    Microsoft Excel MVP

  3. #3
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Excel formula wont work

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    PLEASE PM WHEN YOU HAVE DONE THIS AND I WILL DELETE THIS POST

+ 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