+ Reply to Thread
Results 1 to 4 of 4

Trouble Setting a cell to a value

Hybrid View

jubi23 Trouble Setting a cell to a... 12-18-2007, 10:31 AM
jubi23 anyone atleast have any ideas... 12-18-2007, 12:31 PM
MickG functions 12-18-2007, 01:16 PM
jubi23 yea i tried it outside the... 12-18-2007, 02:52 PM
  1. #1
    Registered User
    Join Date
    12-17-2007
    Posts
    14

    Trouble Setting a cell to a value

    So i have this code, that unmerges some merged cells and then applies border
    then i'm trying to set the value of the empty cells and its not working

    The setting of the values is closer to the bottom of the code
    There are two checks, one msgbox that says "its here"

    and another that says "its here2" after the setting of the values

    the second msgbox never comes up and has me very confused

    anyone got any ideas?


    Function MergeLeftSide1(Target As Variant)
        If Target.MergeCells = False Then
            MsgBox ("don't do anything")
        Else
            RowCnt = Target.Row
            ChkCol = 6
            NumOfRows = Target.MergeArea.Rows.count
            NumOfRows = NumOfRows - 1
            
            ActiveSheet.Range(ActiveSheet.Cells(RowCnt, ChkCol - 1), ActiveSheet.Cells(RowCnt + NumOfRows, ChkCol + 3)).Select
            With Selection
                .UnMerge
                .HorizontalAlignment = xlCenter
                .VerticalAlignment = xlCenter
                .WrapText = False
                .Orientation = 0
                .AddIndent = False
                .IndentLevel = 0
                .ShrinkToFit = False
                .ReadingOrder = xlContext
            End With
    
            
            ActiveSheet.Range(ActiveSheet.Cells(RowCnt, ChkCol - 1), ActiveSheet.Cells(RowCnt, ChkCol + 3)).Select
            With Selection.Borders(xlEdgeLeft)
                .LineStyle = xlContinuous
                .Weight = xlThin
                .ColorIndex = xlAutomatic
            End With
            With Selection.Borders(xlEdgeTop)
                .LineStyle = xlContinuous
                .Weight = xlThin
                .ColorIndex = xlAutomatic
            End With
            With Selection.Borders(xlEdgeBottom)
                .LineStyle = xlContinuous
                .Weight = xlThin
                .ColorIndex = xlAutomatic
            End With
            With Selection.Borders(xlEdgeRight)
                .LineStyle = xlContinuous
                .Weight = xlThin
                .ColorIndex = xlAutomatic
            End With
              
            MsgBox ("its here")
    
            ActiveSheet.Range(Cells(RowCnt + NumOfRows, ChkCol - 1)).Select
            ActiveCell.FormulaR1C1 = "30"
            
            ActiveSheet.Range(Cells(RowCnt + NumOfRows, ChkCol)).Select
            ActiveCell.FormulaR1C1 = "12"
    
            MsgBox ("its here 2")
            
        End If
    End Function

  2. #2
    Registered User
    Join Date
    12-17-2007
    Posts
    14
    anyone atleast have any ideas why it might be skipping that code?
    or appear to be skipping the code

  3. #3
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    functions

    Try running your code as a sub
    Functions return values they don't perform actions with objects.
    Mick G

  4. #4
    Registered User
    Join Date
    12-17-2007
    Posts
    14
    yea i tried it outside the function and all is well
    thats kinda annoying, but o well

    thanks for the help!

+ 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