|
-
Nov 6th, 2012, 06:38 PM
#1
Thread Starter
PowerPoster
[RESOLVED] If cell not empty...AUTOFILL VBA (FormulaR1C1)
Not sure how to explain this, but I'll give it a go.
I'm importing a csv file. After that I'm adding additional columns and values, all using VBA.
I have a small issue with adding a R1C1 formula and fill the formula to the bottom.
Example:
A1 : xxxxx
A2: yyyyy
A3:
A4: zzzzz
A5: sssss
A6: eeeee
A7: jjjjj
In Column B I need to add "ready" if the cell next to it is not empty.
Code:
With Range("B1")
.FormulaR1C1 = "=IF(RC[-1]<>"""",""ready"","""")"
.AutoFill Destination:=Range(.Offset(0, -1), .Offset(0, -1).End(xlDown)).Offset(0, 1)
End With
The autofill adds one after the first empty cell and then stops. How do i change it so it will use the usedRange?
Thanks in advance.
-
Nov 7th, 2012, 04:14 AM
#2
Re: If cell not empty...AUTOFILL VBA (FormulaR1C1)
you can try like
.AutoFill .Resize(.Offset(Rows.Count - .Row, -1).End(xlUp).Row)
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Nov 7th, 2012, 06:26 AM
#3
Thread Starter
PowerPoster
Re: If cell not empty...AUTOFILL VBA (FormulaR1C1)
Thanks, that did it.
When the column is comletely empty it returns an error, but I "solved" it by using "on error resume next". Probably not the proper way to solve it, but I'm saved for the moment.
-
Nov 7th, 2012, 03:24 PM
#4
Re: [RESOLVED] If cell not empty...AUTOFILL VBA (FormulaR1C1)
Probably not the proper way to solve it
i would have to agree
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|