+ Reply to Thread
Results 1 to 5 of 5

Help coding Logical function in VBA code

  1. #1
    Registered User
    Join Date
    12-08-2009
    Location
    Delft, The Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    10

    Help coding Logical function in VBA code

    Hello,

    I was wondering if someone could help me along with coding a logical function in Visual Basic code in a macro. I am a bit new to macro's and VBA in excel.

    The reason why I would like to code this function is because I do not want to put the logical functions in all the cells.
    My cells in the spreadsheet are only 0,3 .. wide and I would like to put some text in some cells.
    The 'false' (i.e. " ") statement in every cell would make it impossible to show text over multiple cells.

    I have an idea of what it should do, but I need a kickstart to know what I am looking for on the web. Some basic examples would help a lot!

    The file is attached, it is a gant chart spreadsheet.

    The idea.
    Please Login or Register  to view this content.
    Hope someone can help me out.

    Thanks, Wiggert.
    Attached Files Attached Files
    Last edited by DonkeyOte; 12-09-2009 at 08:00 AM. Reason: CODE tags not QUOTE tags please

  2. #2
    Registered User
    Join Date
    12-08-2009
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Help coding Logical function in VBA code

    I'm not able to follow exactly what you are trying to do; however, here is an example of VBA code that loops through x number of cells in a column looking for a specific string:

    Please Login or Register  to view this content.
    Last edited by chrns12; 12-09-2009 at 01:39 AM. Reason: Left something out....

  3. #3
    Registered User
    Join Date
    12-08-2009
    Location
    Delft, The Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    10

    Smile Re: Help coding Logical function in VBA code

    Hello chrns12,

    Thanks for the reply.

    This will help a lot! I think this will be enough to get me started and most probably will do the job in a slightly adjusted manner.

    If everything works well I will post the result.

    Thanks for now! Wiggert

  4. #4
    Registered User
    Join Date
    12-08-2009
    Location
    Delft, The Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Help coding Logical function in VBA code

    Help! It's not working yet.

    I would like to use a simple search to find a specified value in an entire row.

    Then when found, I would like to continue the search on the next row finding a different specified value.

    I would like to use two for next loops to be able to use the cell number where the specified values are found and the row number of the specified value.

    When this is all a bit vague. Then I just like to know how I can search a sheet row by row using two for next loops.

    Thanks again! Wiggert

  5. #5
    Registered User
    Join Date
    12-08-2009
    Location
    Delft, The Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Help coding Logical function in VBA code

    Ok, I came up with the following code but I would like to select the entire row or do untill cell is empty. Untill now I haven't been able to integrate that into the code.

    Anyone?

    The search code 'also as attachment.

    Option Explicit
    Dim wsBD2 As Worksheet

    Dim rownumber As Integer
    Dim columnnumber As Integer
    Dim rowProjectNumber As Integer

    Dim columnfrom As Integer
    Dim columnto As Integer

    Dim projectTitle As Integer

    Sub Find_Something()

    Set wsBD2 = Worksheets("Blad1")

    'Activate your starting column and cell
    wsBD2.Range("F4").Activate

    rownumber = 4

    columnfrom = wsBD2.Range("E4").Column
    columnto = wsBD2.Range("J4").Column

    'Set the number of cells in the row you want to search through, example: 1 to 1000
    For rowProjectNumber = wsBD2.Range("D5") To wsBD2.Range("D6")
    'Set projectTitle to whatever you are looking for, example: wsBD2.Range("B2").Value
    projectTitle = wsBD2.Range("D" & CStr(rowProjectNumber)).Value

    'Set the number of cells in the column you want to search through, example: 1 to 1000
    For columnnumber = columnfrom To columnto

    'Check for a match to projectTitle
    wsBD2.Cells(rownumber, columnnumber).Activate

    If ActiveCell.Value = projectTitle Then
    'Do something with what your match
    MsgBox "Found"
    End If

    Next columnnumber

    Next rowProjectNumber

    End Sub
    Thanks, Wiggert
    Attached Files Attached Files

+ Reply to Thread

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