concatenate variables

Linda21

New Member
Joined
Aug 2, 2010
Messages
38
Can someone review the code below? I simply want to concatenate all 3 variables into one string--no spaces. There is something wrong with the last line of code. Also, should these be Variants if they are all text? Thank you!

SDDF_StartRow = 10
SDDF_FundCol = 2
SDDF_EntityCol = 3
SDDF_CodeCol = 7
D_StartRow = 9
D_FundCol = 33
D_EntityCol = 34 'will change depending on detail sheet
D_CodeCol = 32
D_EntityRow = 5
SDDF_Fund = SDDF.Cells(SDDF_StartRow, SDDF_FundCol) 'designate SDDF fund location
D_Fund = RD.Cells(D_StartRow, D_FundCol) 'designate detail sheet fund location
SDDF_Entity = SDDF.Cells(SDDF_StartRow, SDDF_EntityCol) 'designate SDDF entity location
D_Entity = RD.Cells(D_EntityRow, D_EntityCol) 'designate detail sheet entity location - does not change
SDDF_Code = SDDF.Cells(SDDF_StartRow, SDDF_CodeCol) 'designate SDDF detail code location
D_Code = RD.Cells(D_StartRow, D_CodeCol) 'designate detail sheet detail code location
SDDF = SDDF_Fund & SDDF_Entity & SDDF_Code
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Code:
SDDF = WorksheetFunction.Substitute (SDDF_Fund + SDDF_Entity + SDDF_Code, " ", "_")
 
Upvote 0
That code does not work either. Error 438: Object does not support this property or method. Any other ideas? Thanks.
 
Upvote 0
They were Variants. I changed to String and now the code below will not work beginning at the '*'. It worked when they were Variants. Thank you.

Dim SDDF_StartRow As String
Dim SDDF_FundCol As String
Dim SDDF_EntityCol As String
Dim SDDF_CodeCol As String
Dim D_StartRow As String
Dim D_FundCol As String
Dim D_EntityCol As String
Dim D_CodeCol As String
Dim D_EntityRow As String

Sub RIGDetailUpdate()

SDDF_StartRow = 10
SDDF_FundCol = 2
SDDF_EntityCol = 3
SDDF_CodeCol = 7
D_StartRow = 9
D_FundCol = 33
D_EntityCol = 34 'will change depending on detail sheet
D_CodeCol = 32
D_EntityRow = 5

'*' SDDF_Fund = SDDF.Cells(SDDF_StartRow, SDDF_FundCol) 'designate SDDF fund location
D_Fund = RD.Cells(D_StartRow, D_FundCol) 'designate detail sheet fund location
SDDF_Entity = SDDF.Cells(SDDF_StartRow, SDDF_EntityCol) 'designate SDDF entity location
D_Entity = RD.Cells(D_EntityRow, D_EntityCol) 'designate detail sheet entity location - does not change
SDDF_Code = SDDF.Cells(SDDF_StartRow, SDDF_CodeCol) 'designate SDDF detail code location
D_Code = RD.Cells(D_StartRow, D_CodeCol) 'designate detail sheet detail code location
SDDF = WorksheetFunction.Substitute(SDDF_Fund + SDDF_Entity + SDDF_Code, " ", "_")
 
Upvote 0
have you tried changing this
Code:
SDDF_Fund = SDDF.Cells(SDDF_StartRow, SDDF_FundCol)
to this (for each variable in question?)
Code:
SDDF_Fund = SDDF.Cells(SDDF_StartRow, SDDF_FundCol).Value
 
Upvote 0
In the second set of code - there is a line with '*'. I changed this to add .Value as you suggested. Error 1004 - application-defined or object-defined error. It all started because of trying to concatenate using the code suggested by other reader. I needed to change all variants to string. The '*' line worked when they were designated as 'variant'. thanks.
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,789
Members
452,942
Latest member
VijayNewtoExcel

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