VBA Copying Cell Values to 2+ cells Result Not Same

Don Carlos

New Member
Joined
Feb 1, 2016
Messages
5
Excel 2010 VBA

My intention is to copy cell text value (containing a list of information provided by the user) and paste it to two different cells. The intent is to allow the user to edit the record within a userform. If the two text values are not equal, I would enable the "save" and "discard" changes buttons within the userform.

The coding instructions are below:

Code:
tTempText = Trim(Sheet4.Range("RISKNW").Offset(nSelectedRecord, 13).Value)
        Sheet2.Range("RISKIMP1").Value = tTempText
        Sheet2.Range("RISKIMP2").Value = tTempText

The issue is that the "RISKIMP1" and "RISKIMP2" contents are different causing the "save" and "discard" buttons to be enabled when actually no change was made by the user. I checked the contents using a basic text editor and the contents are the same between the two different cells.

I have tried:
1. using TRIM() and still the length of the cell values are different by 2 characters;
2. using LEFT() and taking the shorter length and comparing the trimmed values;
3. copying the formats of a different cell onto the ones in question;
4. as the longer length goes to the first cell, I wrote to three cells and compared the last two with the second cell being the same as the first;
5. wrote contents to three cells and compared the first two; and
5. copied the userform, sheet2 and sheet4 contents into a new spreadsheet.

Your feedback on options are appreciated.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,223,896
Messages
6,175,259
Members
452,626
Latest member
huntinghunter

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