Consulting

Results 1 to 6 of 6

Thread: Solved: If a cell is full

  1. #1

    Solved: If a cell is full

    I have a question,

    I have a macro that copies a sheet from a specific workbook and then i want a macro that creates a column wich if the first cell (for example A1) is there anything written there, in colum AC from the same row will be a formula.

    is that possible?

    tkx

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    It's not clear what you mean by creates a column....
    if A1 has data then enter formula in AC:
    [VBA]If Range("A1").Value <> 0 Then Range("AC1").Formula = "=S1"[/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    Would be something like that, but I need to do in all the cells from column "A"

  4. #4
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Something like this [VBA]
    Dim Rng,Mycell As Range
    Dim Rng1 As String
    Rng1=Range("A65536").End(xlUP).Address
    Set Rng=Range("A:" & Rng1)
    For Each Mycell in Rng
    If Mycell.value <>0 Then Mycell.Offset(0,104).Formula = "=S1"
    End If
    Next Mycell
    [/VBA]
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  5. #5
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    or:
    [VBA]Dim BeginRow As Long
    Dim EndRow As Long
    Dim chkcol As Long
    Dim ROWCNT As Long
    BeginRow = 1
    EndRow = 6000
    chkcol = 1
    For ROWCNT = BeginRow To EndRow
    If Cells(ROWCNT, chkcol).Value <> "" Then
    Cells(ROWCNT, "AC").Formula = "=S1"
    End If
    Next ROWCNT[/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  6. #6
    Tkx lucas! Thats what i was trying 2 do!

    solveD!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •