Quantcast
Channel: Excel IT Pro Discussions forum
Viewing all articles
Browse latest Browse all 11829

VBA Selecting a Range issues.

$
0
0

Hi,

I'm completely new to VBA so I probably have a basic question.

I have a piece of code which sends a mail as soon as the workbooks is saved. Im trying to get a certain range of cells into this mail so people can actually see what has changed.

What I use is this:

.htmlbody = Cellen() & " <br /> " & " hello "

And for Cellen() I made a function:

Function Cellen() As String   

Cellen = Sheets("Blad2").Range("A2").Value & " " & Sheets("Blad2").Range("B2").Value & " " & Sheets("Blad2").Range("C2").Value & " " & Sheets("Blad2").Range("E2").Value   

End Function

This Actually works, but instead of selecting all the cells one by one I would like to select a Range of cells.

For instance A2:E10 or something like that.

I Have tried different things like Sheets("Blad2").Range("A2:A10").Value  or

Sheets("Blad2").Range A2:E10").Value  but that does not give a value or even gives an error.

Also the reason for all the & " " & is that when i dont do that all the values will be next to each other without a space  so its almost not readable.

Could anyone give me a hand here.

Ty


Viewing all articles
Browse latest Browse all 11829

Trending Articles