Results 1 to 4 of 4

Edit a script to work with Column G instead of A

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-14-2014
    Location
    US
    MS-Off Ver
    2013
    Posts
    135

    Edit a script to work with Column G instead of A

    I have script that inputs data in two locations however I have ran into a hiccup. When I try and input my data it is putting it in columns A:E and not G:K

    The first part of this script is working perfect however the part in the section "Data Input for active gradebook weighted key is not". Also is it possible to wrap a if around that part based on if G3 says percentage dont do this if G3 say weighted do this? It might be something I want to add later so figure I may as well try to get that part also.

    Thank you

    Private Sub cmdSubmit_Click()
        Application.ScreenUpdating = False
        Dim NextRw As Long, PointsReceived As Long, startRow As Long
        Dim CelFormat As String, AssignmentType As String
        Dim ws As Worksheet
        Dim rFind As Range
        Dim i As Integer
    
        Set ws = ActiveSheet
        NextRw = ws.Range("G190").End(xlUp).Offset(2, 0).Row
        If NextRw = 7 Then NextRw = 6
        '<< Add data to worksheet >>
        ws.Cells(NextRw + 0, "G") = Me.txtAssignmentName.Value
        ws.Cells(NextRw + 1, "G") = Me.txtDate.Value
        ws.Cells(NextRw + 1, "G") = "Due: " & Me.txtDate.Value
        ws.Cells(NextRw + 2, "G") = Me.txtAssignmentType.Value
    ' *********************************************************************
    ' Data input for active gradebook weighted key
    ' *********************************************************************
        AssignmentType = txtAssignmentType.Value
        If txtPointsReceived.Value = "" Then
            PointsReceived = 1000
        Else
            PointsReceived = txtPointsReceived.Value
        End If
        i = 202
        If AssignmentType = ActiveSheet.Range("G200").Value Then
            For i = 202 To 1000
                If ActiveSheet.Cells(i, 1).Value = "" Then
                    If PointsReceived <> 1000 Then
                        ActiveSheet.Cells(i, 1).Value = PointsReceived
                    End If
                    Exit For
                End If
            Next i
        ElseIf AssignmentType = ActiveSheet.Range("H200").Value Then
            For i = 202 To 1000
                If ActiveSheet.Cells(i, 2).Value = "" Then
                    If PointsReceived <> 1000 Then
                        ActiveSheet.Cells(i, 2).Value = PointsReceived
                    End If
                    Exit For
                End If
            Next i
        ElseIf AssignmentType = ActiveSheet.Range("I200").Value Then
            For i = 202 To 1000
                If ActiveSheet.Cells(i, 3).Value = "" Then
                    If PointsReceived <> 1000 Then
                        ActiveSheet.Cells(i, 3).Value = PointsReceived
                    End If
                    Exit For
                End If
            Next i
        ElseIf AssignmentType = ActiveSheet.Range("J200").Value Then
            For i = 202 To 1000
                If ActiveSheet.Cells(i, 4).Value = "" Then
                    If PointsReceived <> 1000 Then
                        ActiveSheet.Cells(i, 4).Value = PointsReceived
                    End If
                    Exit For
                End If
            Next i
        ElseIf AssignmentType = ActiveSheet.Range("K200").Value Then
            For i = 202 To 1000
                If ActiveSheet.Cells(i, 5).Value = "" Then
                    If PointsReceived <> 1000 Then
                        ActiveSheet.Cells(i, 5).Value = PointsReceived
                    End If
                    Exit For
                End If
            Next i
        End If
    
    ' *********************************************************************
    ' Force formatting active gradebook received and possible
    ' *********************************************************************
        If (Me.txtPointsReceived.Value & "X" = "X") Then
            ws.Cells(NextRw + 0, "J").Value = "-"
        Else
            If InStr(1, txtPointsReceived, "%") = 0 Then
                CelFormat = "0.00"
            Else
                CelFormat = "0.00%"
            End If
            With ws.Cells(NextRw + 0, "J")
                .NumberFormat = CelFormat
                .Value = Me.txtPointsReceived.Value
            End With
        End If
        If InStr(1, txtPointsPossible, "%") = 0 Then
            CelFormat = """/"" 0.00"
        Else
            CelFormat = """/"" 0.00%"
        End If
        With ws.Cells(NextRw + 0, "K")
            .NumberFormat = CelFormat
            .Value = Me.txtPointsPossible.Value
        End With
    
        Unload Me
    End Sub

    Last second thought *** Can vba do formulas such as Sumif average and VLOOPUP on a veryhidden sheet?
    Last edited by Mr_Bill; 09-16-2014 at 10:52 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 03-03-2014, 10:56 AM
  2. Search and Edit Script Needed
    By Rey Ocampo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-20-2012, 04:22 PM
  3. Edit Script not to look at one of my sheets
    By realniceguy5000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-15-2008, 01:35 PM
  4. script manipulate and edit an Excel spreadsheet
    By wofans in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-15-2007, 03:31 PM
  5. [SOLVED] stop script if dates are missing, edit help...
    By RompStar in forum Excel General
    Replies: 13
    Last Post: 05-05-2005, 06:06 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