edit the row data by highlighted cells

i need the vba code to edit the data in a row  by highlighted cells
plz look into the attachment all details are given
Avinash SinghAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Neil FlemingConsultant and developerCommented:
I think the attached does what you want.

Here's the code attached to the button in the file uploaded
Option Explicit

Sub GetData()
Dim wSource As Worksheet, wTarg As Worksheet
Dim rSource As Range, rTarg As Range, rCell As Range
Dim iStart As Long, i As Long, iLast As Long
Dim highlight As Boolean, gap As Boolean

Set wSource = ActiveSheet
Set wTarg = ActiveWorkbook.Worksheets.Add

'create source range
Set rSource = wSource.Cells(1, 1).CurrentRegion
Set rSource = rSource.Resize(1, rSource.Columns.Count - 1).Offset(1, 0)
'target range:
Set rTarg = wTarg.Cells(1, 1)
    gap = False
    highlight = False
    'start at second cell in each row
    iStart = 2
    For i = 2 To rSource.Columns.Count
    'stop at blank cell:
    If rSource(i) = "" Then Exit For
        If rSource(i).Interior.Color <> RGB(255, 255, 255) Then
            If highlight Then
            'do nothing if cell is next to highlighted cell
            highlight = True
            'mark second highlighted cell
            If gap Then iStart = i
            End If
        If highlight Then gap = True
        highlight = False
        End If
'don't use iStart as first column if no data after it
iLast = i - 1
If iLast = iStart Then iStart = 2

'insert row title
rTarg = rSource(1)
Set rTarg = rTarg.Offset(0, 1)

'copy found data
For i = iStart To iLast
rTarg = rSource(i)
rTarg.Interior.Color = rSource(i).Interior.Color
Set rTarg = rTarg.Offset(0, 1)

'next source row
Set rSource = rSource.Offset(1, 0)
'next target row
Set rTarg = rTarg.Offset(1, 1 + (rTarg.Column * -1))
'stop at first blank row
Loop Until rSource(1) = ""

End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Avinash SinghAuthor Commented:
Awesome sir thnx sir for giving ur precious time to this post  u r the best of best
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:

You are supposed to accept the answer given by Neil Fleming to mark your question as Solved.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Neil FlemingConsultant and developerCommented:
Many thanks Neeraj, for spotting that. I'm sure it was just a slip of the mouse.
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome Neil! I guessed the same.
Avinash SinghAuthor Commented:
best solution by Neil Fleming sir
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.