Results 1 to 3 of 3

How to simplify the VBA code from function to send rows into send range

Threaded View

herukuncahyono How to simplify the VBA code... 07-12-2013, 08:10 PM
HaHoBe Re: How to simplify the VBA... 07-13-2013, 02:54 AM
herukuncahyono Re: How to simplify the VBA... 07-13-2013, 03:11 AM
  1. #1
    Forum Contributor
    Join Date
    03-11-2009
    Location
    Indonesia
    MS-Off Ver
    Excel 2019
    Posts
    252

    How to simplify the VBA code from function to send rows into send range

    Hi,
    I have a code where the function is to send a certain amount of data from a single rows value from one sheet to another sheet by name in a specific cell.
    my question is whether function can be simplified if we want to send 2 or more rows because this is the appropriate code below just to send the value from the 2 rows on the 8 column value
    And will become a long code if we want to send 50 rows

    Dim nextRow As Range
    Dim lngCounter As Long
    
    If Range("B3").Value = "" Then Exit Sub 'variable-1
    On Error Resume Next
    With Sheets(Range("B3").Value) 'variable-2
        Set nextRow = .Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0)
    End With
    If Not nextRow Is Nothing Then
      For lngCounter = 1 To 8
        Select Case lngCounter
          Case 1
            nextRow = "'" & Cells(3, 2 + lngCounter).Value 'variabel-3
          Case Else
            nextRow.Offset(0, lngCounter - 1) = Cells(3, 2 + lngCounter).Value 'variabel-4
        End Select
      Next lngCounter
    End If
    
    If Range("B4").Value = "" Then Exit Sub
    On Error Resume Next
    With Sheets(Range("B4").Value)
        Set nextRow = .Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0)
    End With
    If Not nextRow Is Nothing Then
      For lngCounter = 1 To 8
        Select Case lngCounter
          Case 1
            nextRow = "'" & Cells(4, 2 + lngCounter).Value
          Case Else
            nextRow.Offset(0, lngCounter - 1) = Cells(4, 2 + lngCounter).Value
        End Select
      Next lngCounter
    End If
    If the code "send ROWS value from one sheet to other in the next blank row" how if simplified to " send RANGE value from one sheet to other in the next blank row"
    Thanks for the help
    Last edited by herukuncahyono; 07-13-2013 at 03:11 AM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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