+ Reply to Thread
Results 1 to 7 of 7

Macro changing text to "?/??" format???

Hybrid View

adam2308 Macro changing text to "?/??"... 08-28-2009, 07:27 AM
adam2308 Re: Macro changing text to... 08-29-2009, 12:47 PM
shg Re: Macro changing text to... 08-29-2009, 01:06 PM
adam2308 Re: Macro changing text to... 09-11-2009, 11:31 AM
adam2308 Re: Macro changing text to... 09-11-2009, 03:41 PM
adam2308 Re: Macro changing text to... 09-13-2009, 08:51 AM
adam2308 Re: Macro changing text to... 09-13-2009, 05:51 PM
  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    467

    Macro changing text to "?/??" format???

    I have the code below in a macro which seemed to work fine but somehow it manages to convert cells in text format into "?/??" format when the macro is run. This bit relates to the part of the code highlighted in red below... Any questions please ask, this is causing me major problems and need to fix it asap. I've attached a copy of the workbook if it helps. Unfortunately, to run the macro you will need to change the file directory to one that will suit.

    Sub save()
    '
    ' save Macro
    ' Macro recorded 23/11/2006 by Administrator
    '
    
    '
        Dim cell    As Range
        Dim rDel    As Range
    
        ' *********************************
        With Sheets("Events")
            .Range("A60000", .Cells(.Rows.Count, .Columns.Count)).Delete
            .Cells.Copy
        End With
    
        Workbooks.Open Filename:="Z:\Baseball\Baseball_Ev.csv"
        Range("A1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats, _
                                Operation:=xlNone, SkipBlanks:=False, Transpose:=False
        Set rDel = Nothing
        
        With ActiveSheet.UsedRange
            .Value = .Value
            For Each cell In Intersect(.Cells, .Columns("A"))
                If Len(cell.Text) = 0 Then
                    If rDel Is Nothing Then Set rDel = cell
                    Set rDel = Union(rDel, cell)
                End If
            Next cell
        End With
    
        If Not rDel Is Nothing Then rDel.EntireRow.Delete
    
        ActiveWorkbook.Close SaveChanges:=True
    
        ' *********************************
        With Sheets("Markets")
            .Range("A60000", .Cells(.Rows.Count, .Columns.Count)).Delete
            .Cells.Copy
        End With
        Workbooks.Open Filename:="Z:\Baseball\Baseball_Mkt.csv"
        Range("A1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats, _
                                Operation:=xlNone, SkipBlanks:=False, Transpose:=False
        
        Set rDel = Nothing
        
        With ActiveSheet.UsedRange
            .Value = .Value
            For Each cell In Intersect(.Cells, .Columns("A"))
                If Len(cell.Text) = 0 Then
                    If rDel Is Nothing Then Set rDel = cell
                    Set rDel = Union(rDel, cell)
                End If
            Next cell
        End With
    
        If Not rDel Is Nothing Then rDel.EntireRow.Delete
    
        ActiveWorkbook.Close SaveChanges:=True
    
        ' *********************************
        With Sheets("Selections")
            .Range("A60000", .Cells(.Rows.Count, .Columns.Count)).Delete
            .Cells.Copy
        End With
        Workbooks.Open Filename:="Z:\Baseball\Baseball_Sel.csv"
        Range("A1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats, _
                                Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    
        Set rDel = Nothing
        
        With ActiveSheet.UsedRange
            .Value = .Value
            For Each cell In Intersect(.Cells, .Columns("A"))
                If Len(cell.Text) = 0 Then
                    If rDel Is Nothing Then Set rDel = cell
                    Set rDel = Union(rDel, cell)
                End If
            Next cell
        End With
    
        If Not rDel Is Nothing Then rDel.EntireRow.Delete
    
        ActiveWorkbook.Close SaveChanges:=True
        Sheets("Results").Select
        Cells.Select
        Selection.Copy
        Workbooks.Open Filename:="Z:\Baseball\Baseball_Res.csv"
        Cells.Select
        Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
            xlNone, SkipBlanks:=False, Transpose:=False
        ActiveWorkbook.save
        ActiveWorkbook.Close
        Sheets("Input").Select
        Range("B3").Select
            Sheets("Printout Sheet").Select
        ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
        Sheets("Input").Select
        Range("B3").Select
    End Sub
    Attached Files Attached Files
    Last edited by adam2308; 09-16-2009 at 09:14 AM.

  2. #2
    Forum Contributor
    Join Date
    02-20-2009
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    467

    Re: Macro changing text to "?/??" format???

    Could i possibly bump this thread up... Any suggestions would be greatly appreciated.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Macro changing text to "?/??" format???

    The code is pasting whatever format is in the copied cells. If you just want to paste values, change Paste:=xlPasteValuesAndNumberFormats to Paste:=xlPasteValues
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Contributor
    Join Date
    02-20-2009
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    467

    Re: Macro changing text to "?/??" format???

    Sorry for only just replying on this, got busy with something else...

    I can't paste just the values with this as this would only work the fractions 4/6 and 6/4, other fractions would paste the numeric value i.e. 7/4 would paste 1.75 and i need to keep it to the fractional format.

    I have tried to replicate the macro manually (without deleting all the rows that column A is blank) and it works ok but won't work when using the macro button.

  5. #5
    Forum Contributor
    Join Date
    02-20-2009
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    467

    Re: Macro changing text to "?/??" format???

    Can anyone help with this or am i not making myself clear enough? Like i said earlier you may need to setup 3 csv files and alter the file directory in the VBA to suit to see the macro work for yourself.

  6. #6
    Forum Contributor
    Join Date
    02-20-2009
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    467

    Re: Macro changing text to "?/??" format???

    Can anyone help?

    Thanks.

  7. #7
    Forum Contributor
    Join Date
    02-20-2009
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    467

    Re: Macro changing text to "?/??" format???

    I've just found out (by trial and error) that if i delete this portion of the red code above, the 4/6 remains as 4/6 and does not round down to 2/3.

        Set rDel = Nothing
        
        With ActiveSheet.UsedRange
            .Value = .Value
            For Each cell In Intersect(.Cells, .Columns("A"))
                If Len(cell.Text) = 0 Then
                    If rDel Is Nothing Then Set rDel = cell
                    Set rDel = Union(rDel, cell)
                End If
            Next cell
        End With
    
        If Not rDel Is Nothing Then rDel.EntireRow.Delete
    As far as i know this code should simply delete any rows where the column is blank. I don't understand how it would affect the rest of the code whether it was in the macro or not?

    Any help please?

+ 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