Using a function in VBA across a range

Calum

New Member
Joined
Aug 13, 2015
Messages
24
I need to pull in two values across two cells on a source document and include it on a column header on a worksheet:

Workbooks(today_name).Worksheets(5).Activate
date_today = Range("E3").Value
file_name = Range("E1:E2").Value
Workbooks(wkbk_name).Worksheets("Provision").Activate
Range("B27").Value = Range("B27").Value & file_name & " " & date_today

It does not like the third line with the range value across a range of two cells and comes back as a type mismatch.

Any help would be most appreciated!
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Hi,

try changing this line:

Rich (BB code):
Range("B27").Value = Range("B27").Value & file_name & " " & date_today

to this:

Rich (BB code):
Range("B27").Value = Range("B27").Value & file_name(1, 1) & file_name(2, 1) & " " & date_today

Dave
 
Upvote 0
Hi Dave,

None of the code now runs with the edit above. It skips straight to "Compile error: Expected array"

Do I need to declare anything beforehand?
 
Upvote 0
Hi Dave,

None of the code now runs with the edit above. It skips straight to "Compile error: Expected array"

your your variable file_name should be dimensioned as a variant.

Dave
 
Upvote 0

Forum statistics

Threads
1,215,343
Messages
6,124,400
Members
449,156
Latest member
LSchleppi

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