Results 1 to 6 of 6

if between two numbers

Threaded View

  1. #6
    Registered User
    Join Date
    12-17-2008
    Location
    edinburgh, uk
    Posts
    46

    Re: if between two numbers

    Updated code but it's still not working

    Basically it's just copying cells 1 to 22 from the CMDB sheet and pasting them in the SDC_PROC sheet in D2 - D23. Not sure what I've done wrong

    Sub IsBetween()
    ' ### INITIAL SETUP
    Dim INCR As Long
    Dim cell As Range
    Dim testvalue As Variant
    Dim lwr As Variant
    Dim upr As Variant
    Dim equaltype As Boolean
    Dim IsBetween As Integer
    Dim i As Long
    Dim j As Long
    Dim sheet As Worksheet
    Dim UsedRange As Range
    
    Application.ScreenUpdating = False
    
    Sheets("CMDB").Select
    Set sheet = ActiveSheet
    Set cell = sheet.UsedRange
    
    ' ### START LOOP FOR ALL CMDB ASSETS
    For i = 1 To cell.Rows.Count
        INCR = 1
        ' ### START LOOP FOR ALL ZONES
        For j = 1 To 22
    
             INCR = INCR + 1
             Sheets("SDC_PROD").Select
             lwr = ("D" & j)
             upr = ("E" & j)
             Sheets("CMDB").Select
             testvalue = ("E" & i)
    
                If testvalue >= lwr And testvalue <= upr Then
                     Sheets("SDC_PROD").Select
                     Range("A" & j).Select
                     Application.CutCopyMode = False
                     Selection.Copy
                     Sheets("CMDB").Select
                     Range("D" & INCR).Select
                     ActiveSheet.Paste
                     
                End If
        
             ' ### END ZONE LOOP
             Next j
             
    ' ### END CMDB ASSETS LOOP
    Next i
    
    Application.ScreenUpdating = True
    End Sub
    Last edited by mattmac; 01-24-2011 at 07:47 AM. Reason: updated code

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