Target.Column + 8?

ashbee

New Member
Joined
Sep 16, 2019
Messages
20
Hello

I have an Excel spreadsheet that will be used for data entry without userforms (to allow for Mac users). I intend on password protecting it to make data entry easier. It works as I hope however I found the code on the internet and whilst it works I don't quite understand one line of code so hoping someone can help.

In the cell change VBA code, I've put

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("E5:H9")) Is Nothing And Range("B4").Value = False And Range("B3").Value = False Then
Cells(Range("B2").Value, Cells(Target.Row, Target.Column + 8).Value).Value = Target.Value
End If


End Sub

What does the + 8 stand for? If I have a differently formatted sheet I want to understand what I might need to replace the 8 with. Any guidance is appreciated.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi & welcome to MrExcel
It is adding 8 to the column number where the change was made, so if you changed a value in col E (column 5) that would give 5+8 = 13 which is column M and if you changed the value in col H it would give you col P
 
Last edited:
Upvote 0
I have an Excel spreadsheet that will be used for data entry without userforms (to allow for Mac users)

FYI, Mac users can use userforms. (they just can't build them if they use a version later than 2011)
 
Upvote 0
FYI, Mac users can use userforms. (they just can't build them if they use a version later than 2011)

That's really useful to know. I wanted to use pop-up forms on cell selection to make it easier for them to choose from a long list of options. Thank you so much
 
Upvote 0
Thanks it's starting to make sense as I have data mapping in column M which gives the reference to the column the change should be made to BUT then how is the same +8 working if my column is G so 7 plus the 8 = 15 which is column N but I have no reference data in N?

Here is a screenshot of the columns I'm using:
https://ibb.co/M1xgXhM

I'm missing something here..

M1xgXhM
 
Upvote 0
That code only triggers if you change a value in the range E5:H9
 
Upvote 0
Thank you, I understand now! Oh the feeling of enlightenment!! I had a feeling I was missing something really obvious and I was.
 
Upvote 0
That code only triggers if you change a value in the range E5:H9

Thank you I understand now! The amazing feeling of enlightenment. I had a feeling I was missing something really obvious but this sentence helped it click into place. Thanks again
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

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