Generate serial numbers

Re: Need help to generate serial numbers as described in the image

Can you please suggest modification to make this code work on locked input cells..??
 
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Re: Need help to generate serial numbers as described in the image

Please sent an example of your current sheet data.
 
Upvote 0
Re: Need help to generate serial numbers as described in the image

Unfortunately because your file consists of Images of your actual sheets I can not run code on it. Please send a copy of the actual file with the current code attached.
 
Upvote 0
Is there any other options to attach excel file than Google drive method...!? Because Gmail servers are blocked in my office..
 
Upvote 0
Try this for data in "Input Sheet" and results in "Output Sheet".
Code:
[COLOR="Navy"]Sub[/COLOR] MG29Aug59
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, nRng [COLOR="Navy"]As[/COLOR] Range, R [COLOR="Navy"]As[/COLOR] Range, Rr [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] RwMax [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Rw [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]With[/COLOR] Sheets("Input Sheet")
    [COLOR="Navy"]Set[/COLOR] Rng = .Range(.Range("E2"), .Range("E" & Rows.Count).End(xlUp))
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
[COLOR="Navy"]If[/COLOR] Not Dn.Value = "Variant" [COLOR="Navy"]Then[/COLOR]
    [COLOR="Navy"]If[/COLOR] nRng [COLOR="Navy"]Is[/COLOR] Nothing [COLOR="Navy"]Then[/COLOR] [COLOR="Navy"]Set[/COLOR] nRng = Dn Else [COLOR="Navy"]Set[/COLOR] nRng = Union(nRng, Dn)
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] Dn
Rw = 1
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Rr [COLOR="Navy"]In[/COLOR] nRng.Areas
RwMax = Application.Max(Rr.Offset(, 1).Value) + 1
ReDim Ray(1 To RwMax, 1 To Rr.Count)
   
   [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] R [COLOR="Navy"]In[/COLOR] Rr
        [COLOR="Navy"]If[/COLOR] R.Offset(, 1) <> "" [COLOR="Navy"]Then[/COLOR]
            Ac = Ac + 1
            Ray(1, Ac) = R.Value
           [COLOR="Navy"]For[/COLOR] n = 1 To R.Offset(, 1).Value
            Ray(n + 1, Ac) = n
            [COLOR="Navy"]Next[/COLOR] n
        [COLOR="Navy"]End[/COLOR] If
    [COLOR="Navy"]Next[/COLOR] R
[COLOR="Navy"]With[/COLOR] Sheets("Output Sheet").Range("c7").Offset(Rw).Resize(RwMax, Ac)
  .Value = Ray
[COLOR="Navy"]End[/COLOR] With
Rw = Rw + RwMax + 5
Ac = 0
[COLOR="Navy"]Next[/COLOR] Rr
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]

If your "Input Sheet" is protected . Please describe how it is protected

Regards Mick
 
Upvote 0
Format cells > protection>locked

review> protect sheet> password locking (with allow user to select locked and unlocked cells)
 
Upvote 0
Assuming its the sheet your writing to (Output Sheet) that your protecting, change the code as below:-
Alter "Password" to suit !!
Code:
With Sheets("Output Sheet").Range("c7").Offset(Rw).Resize(RwMax, Ac)
  .Parent.Unprotect Password:="mick"
  .Value = Ray
 .Parent.Protect Password:="mick"
End With
 
Upvote 0
As the code is not altering the data on "Input Sheet" you soul not need to "unprotect" it.!!!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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