jamesblack90
New Member
- Joined
- Jun 9, 2015
- Messages
- 44
Hey guys,
This is the first thing I've ever created in excel, so teaching myself from google as I go. There are two parts to my question, first of all, I am getting an 'object required' error when this code runs and it highlight the sub declaration as the issue...
Basically I have the user input (up to) four names into Home!C20, 22, 24 and 26. I want the code to assign names(j) to the text that's been input into each of those cells (I originally had a really long and complicated if statements to test what cells were empty etc - a really silly way of doing it now that I discovered arrays). If anyone knows why I'm getting this error that would be great!
My second question would be, how do I then write something that determines how many names there are and inserts into a specific cell "Proposal for [name 1], [name 2]..." etc etc while putting the comma and the 'and' in the correct spot in the sentence (this was initially done in my super bad if statements setting an str variable manually, but surely there must be an easier way?
Thank you everyone in advance, I'm sure I'll have many, many more questions to come, but hopefully as I learn I'll be able to contribute back to you all as well
Cheers
This is the first thing I've ever created in excel, so teaching myself from google as I go. There are two parts to my question, first of all, I am getting an 'object required' error when this code runs and it highlight the sub declaration as the issue...
Code:
Private Sub get_names()
Dim names(4) As String
Dim i As Integer, j As Integer
Set i = 20
Set j = 1
Do Until i = 26
If IsEmpty(Home!Cells(i, 3)) Then
names(1) = "Please enter names on Home Page"
Exit Do
End If
names(j) = Home!Cells(i, 3).Value
i = i + 2
j = j + 1
Loop
End Sub
Basically I have the user input (up to) four names into Home!C20, 22, 24 and 26. I want the code to assign names(j) to the text that's been input into each of those cells (I originally had a really long and complicated if statements to test what cells were empty etc - a really silly way of doing it now that I discovered arrays). If anyone knows why I'm getting this error that would be great!
My second question would be, how do I then write something that determines how many names there are and inserts into a specific cell "Proposal for [name 1], [name 2]..." etc etc while putting the comma and the 'and' in the correct spot in the sentence (this was initially done in my super bad if statements setting an str variable manually, but surely there must be an easier way?
Thank you everyone in advance, I'm sure I'll have many, many more questions to come, but hopefully as I learn I'll be able to contribute back to you all as well
Cheers