AutoFill Question

golfnut019

Board Regular
Joined
Nov 11, 2005
Messages
58
Range("O2").Formula = [H2] & " " & [I2] & ", " & [J2] & ", " & [K2] & " " & [L2]
With ActiveSheet
Set rngData = .Range("A2:A" & .Cells(.Rows.Count, "A").End(xlUp).Row)
Set rngFormula = .Range("O2")
rngFormula.AutoFill _
Destination:=.Range(rngFormula, _
.Cells(rngData.Rows(rngData.Rows.Count).Row, rngFormula.Column))
End With


When I run this, the cell contains the data and not the formula hence when it autofills it increments the address and not the formula parameters.

So cell 1 = 123 Main Street, cell 2 = 124 Main Street, cell 3 = 125 Main street and so on.

It should be cell 1 = 123 Main street, cell2 = 345 Jones Ave. ( depending on what is stored in cells H through J )



Any help on this?
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi

YOu are putting in a text string and not a formula

change
Range("O2").Formula = [H2] & " " & [I2] & ", " & [J2] & ", " & [K2] & " " & [L2]

to

Range("O2").Formula = "=H2 & "" "" & I2 & "", "" & J2 & "", "" & K2 & "" "" & L2"


Tony
 
Upvote 0
Couldn't you just use something like this ...

Code:
Range("O2:O" & Cells(Rows.Count, "A").End(xlUp).Row).Formula = "=H2&I2&J2&K2&L2"

instead of all that?
 
Upvote 0
Range("O2").Formula= "=[H2] & " " & [I2] & ", " & [J2] & ", " & [K2] & " " & [L2]"

Copied directly from my code.


I'm getting a compile error?
 
Upvote 0
firefytr said:
Couldn't you just use something like this ...

Code:
Range("O2:O" & Cells(Rows.Count, "A").End(xlUp).Row).Formula = "=H2&I2&J2&K2&L2"

instead of all that?


I would have if I was good at this stuff. Thanks! I'll try that.
 
Upvote 0
firefytr said:
Couldn't you just use something like this ...

Code:
Range("O2:O" & Cells(Rows.Count, "A").End(xlUp).Row).Formula = "=H2&I2&J2&K2&L2"

instead of all that?



If I wanted to put spaces or commas between H2 and I2 and etc, how would I go about doing that?
 
Upvote 0
Code:
Range("O2:O" & Cells(Rows.Count, "A").End(xlUp).Row).Formula = "=H2&"",""&I2&J2&K2&L2"

.. or ..

Code:
Range("O2:O" & Cells(Rows.Count, "A").End(xlUp).Row).Formula = "=H2&"" ""&I2&J2&K2&L2"
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,739
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top