Results 1 to 18 of 18

IF conditions have to be altered

Threaded View

  1. #1
    Forum Contributor
    Join Date
    09-19-2017
    Location
    London
    MS-Off Ver
    2015
    Posts
    169

    Question IF conditions have to be altered

    Hi,

    I have created a code but I still fail to figure out how to change the condition based on my requirement. The code was supposed to fill in details about cell range in DTE sheet to the other sheet (Definitions). The outcome: Capture2.JPG

    But I actually wanted this code to update the table to become: Target.JPG

    I strongly believe that my condition has to be altered but I'm not sure how as the code has to captured the cell ranges of each table (in target image the cell ranges are different) in DTE sheet. The number of tables in this sheet will change from time to time.

    Anyone can help me to alter this? I have been thinking for hours yet nothing came in mind.

    Long code:
    Sub Test2()
    Dim rw  As Long, x As Long, lr As Long, r As Long, g As Long
    lr = Sheets("DTE").Cells(Rows.Count, 1).End(xlUp).Row
    rw = 1
    g = 17
        For x = 1 To lr
            If Sheets("DTE").Cells(x, 1) = Sheets("DTE").Range("K2") Then rw = rw + 1 'the condition that has to be altered
            If rw = 6 Then 'the condition that has to be altered, the data can be lesser than 6 but more than 0
                Dim cel As Range
                Dim Width As Double
                Dim Height As Double
                Dim lrD As Long
                For Each cel In Sheets("DTE").Range("A" & (rw - 5) & ":" & "G" & rw).Columns(1) 'the condition that has to be altered
                    Height = cel.Height
                Next cel
                For Each cel In Sheets("DTE").Range("A" & (rw - 5) & ":" & "G" & rw).Rows(1) 'the condition that has to be altered
                    Width = cel.Width
                Next cel
                With Sheets("Definitions")
                    lrD = .Cells(Rows.Count, 1).End(xlUp).Row + 1
                    If IsEmpty(.Cells(x, 1)) = True Then
                        .Cells(lrD, 1) = "DTE"
                        .Cells(lrD, 2) = "A" & (rw - 5) & ":" & "G" & rw 'the condition that has to be altered
                        .Cells(lrD, 3) = "Range"
                        .Cells(lrD, 4) = g
                         g = g + 1
                        .Cells(lrD, 5) = "Table"
                        .Cells(lrD, 6) = "1.50"
                        .Cells(lrD, 7) = "0.5"
                        .Cells(lrD, 8) = Round(Height / 72, 2)
                        .Cells(lrD, 9) = Round(Width / 72, 2)
                    End If
                End With
                rw = 1
            End If
        Next
    End Sub
    A small update:

    I have tried to add:
     For x = 1 To lr
                If Not IsEmpty(Sheets("DTE").Cells(x, 1)) Then rw = rw + 1
                myArray = Sheets("DTE").Range("A1:G" & rw)
                
                Do Until IsEmpty(Sheets("DTE").Cells(x, 1))
                    Do Until Sheets("DTE").Cells(x + 1, 1) = "Music"
                Dim cel As Range
                Dim Width As Double
    and also:
    For Each cel In Sheets("DTE").Range("A" & "address from array" & ":" & "G" & "address from array").Columns(1)
                    Height = cel.Height
                Next cel
                For Each cel In Sheets("DTE").Range("A" & "address from array" & ":" & "G" & "address from array").Rows(1)
                    Width = cel.Width
    "A" & "address from array" & ":" & "G" & "address from array"
    P/s: Not sure how can I create the line where the right address from the array can be selected, probably need an iteration?
    Attached Files Attached Files
    Last edited by ell_; 01-23-2018 at 04:44 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Need Worksheet Formula Corrected to use for VBA Macro
    By dosbirn in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-19-2013, 12:23 PM
  2. Check if Name exists and replace it with corrected name and ID
    By chris0228 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-05-2012, 07:27 PM
  3. Corrected: Need help with input Box variable
    By ybortony in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-22-2012, 03:33 AM
  4. Calculating a corrected forecast
    By saved1ne in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-21-2012, 11:07 AM
  5. [SOLVED] VB Code Corrected Solutions
    By RichIT in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-11-2006, 04:20 AM
  6. Combining columns corrected
    By jezzica85 in forum Excel General
    Replies: 2
    Last Post: 03-11-2006, 08:30 AM
  7. [SOLVED] IF AND question corrected
    By Lee in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-06-2005, 03:05 AM
  8. [SOLVED] Array formula reference (Corrected)
    By JAK in forum Excel General
    Replies: 4
    Last Post: 02-22-2005, 12:06 AM

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