I like to create a macro that can automate the process of copying the active cell downward as long as the column D is not empty bearing in mind that there maybe empty rows in column D. It has to be intelligent enoug to skip empty rows.
I like to create a macro that can automate the process of copying the active cell downward as long as the column D is not empty bearing in mind that there maybe empty rows in column D. It has to be intelligent enoug to skip empty rows.
[vba]
ActiveCell.Copy Activecell.Resize(Cells(Rows.Count,"D").End(xlUp).Row)
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
The macro is copying down as what I want to but I did not make it clear enough that if cell in column D is empty the corresponding cell in the active column should also be empty.
Maybe this
[vba]
With ActiveCell
.Offset(1, 0).Resize(Cells(Rows.Count, "D").End(xlUp).Row).FormulaR1C1 = _
"=IF(RC4="""","""",R" & .Row & "C)"
End With
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
I don't know what I am doing wrong, I could not get the result I want. While executing the code there is a circular reference error. Secondly only the cell below the active cell is copied but the content is not as the active cell. The data is the copied cell is "=IF($D2="","",D$1)". ???
Which is the activecell when you run it?
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
My mistake. I have it the other way around. It is now working. thx
I spoke too fast. Although now the code is copying down the active cell but instead of copying the content of the active cell this is copied, "=IF($D2="","",D$1)"
But isn't the result the value of the activecell?
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
I also ask again, what is the activecell when you run this?
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
No, the active cell have a different value. The formula is Cell A1 (the active cell) is E1+F1
E1+F1 is two cells, there is only one activecell.
It must be me, but you guys are really confusing me today.
Here is another suggesrion
[vba]
Dim LastRow As Long
Dim rng As Range
With ActiveCell
LastRow = Cells(Rows.Count, "D").End(xlUp).Row
Set rng = .Resize(LastRow).SpecialCells(xlCellTypeBlanks)
.Copy .Resize(LastRow)
rng.ClearContents
End With
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Sorry, the active is A1 which has a formula of E1+F1.
Modification of my last offering then
[vba]
Dim LastRow As Long
Dim rng As Range
With ActiveCell
LastRow = Cells(Rows.Count, "D").End(xlUp).Row
Set rng = Cells(.Row + 1, "D").Resize(LastRow).SpecialCells(xlCellTypeBlanks).Offset(0, .Column - 4)
.Copy .Resize(LastRow)
rng.ClearContents
End With
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Thx. It now appears to be working the way I hope it would.
Thx. It now appears to be working the way I hope it would.
Great, we finally got there :smile
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Xld,
I wonder if you could help to improve on this macro. At the present moment this macro is very specific as to the reference "criteria" position, which is to the 4 position to the right of the active cell. What should the codes be if it to the right? Can a input box be created to ask for input of the reference cell? That will be wonderful if this can be done.
Thx in advance for any suggestionn and help.
Try this
[vba]
Dim LastRow As Long
Dim StartCell As Range
Dim rng As Range
Set StartCell = Application.InputBox("Select first cell of match range with the mouse", Type:=8)
If Not StartCell Is Nothing Then
With ActiveCell
LastRow = Cells(Rows.Count, StartCell.Column).End(xlUp).Row
.Offset(1, 0).Resize(LastRow - 1).ClearContents
Set rng = Cells(.Row + 1, StartCell.Column).Resize(LastRow).SpecialCells(xlCellTypeBlanks).Offset(0, .Column - StartCell.Column)
.Copy .Resize(LastRow)
rng.ClearContents
End With
End If
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Xld,
The same problem as before. When pasting down the active cell it is suppose to skip over blank reference cell and continue pasting when the reference cell is not empty. Hope I make sense.