Update certain cell with VBA

Ajax

New member
Local time
Tomorrow, 08:11
Joined
Oct 27, 2008
Messages
3
HI All,
This is my very first forum message over here.
I m trying to update all the blank cells in A with the Value starting with "Try" until the column A encounter "Totals" value in cell. Then continue doing this step for the rest of the spreadsheet like, Try 2 for the next lot.
I have attached my excel data the data to copy is in yellow and the data to be updated to is in red.

Here is the VBA for the excel file which doesnt do what I need it to do. :)
Any help ASAP would be appreciated.
Thanks.

Sub Update()

Dim LRow As Integer

LRow = 1

'Move through records until an empty cell is found in column A
While IsEmpty(Range("B" & CStr(LRow)).Value) = False

'If cell B displays "Extn." then move the row to

If Range("B" & CStr(LRow)).Value = "Extn." Then
'Move the row

LRow = LRow - 1

Range("C" & LRow & ":C" & LRow).Select
Selection.Copy

LRow = LRow + 1
Do While IsEmpty(Range("C" & CStr(LRow)).Value) = True
Range("A" & LRow + 1).Select
ActiveSheet.Paste
Loop

End If
LRow = LRow + 1
Wend

End Sub
 

Attachments

Only came across this today so may be to late.
Changes are in red

Brian

Sub Update()

Dim LRow As Integer

LRow = 1

'Move through records until an empty cell is found in column A
While IsEmpty(Range("B" & CStr(LRow)).Value) = False

'If cell B displays "Extn." then move the row to

If Range("B" & CStr(LRow)).Value = "E" Then
'Move the row
LRow = LRow - 1

avalue = Range("C" & LRow & ":C" & LRow).Value

LRow = LRow + 2
Do While IsEmpty(Range("a" & CStr(LRow)).Value) = True
Range("A" & LRow).Value = avalue
LRow = LRow + 1

Loop

End If
LRow = LRow + 1
Wend

End Sub
 
Thanks Heaps Brianwarnock..!
Appreciate the help. Its never too late..! :)
Cheers,
Ajax
 
HI Brianwarnock,
I have another request which I m having trouble with.
I was wondering if for example the same file is a text file and I need to read that text file and then write the contents of the text file in an ms access table how would i do that?
As well, then write a VBA in ms access to do exactly the same procedure which has been done below.

But as the contents of the files are delimited by "" and a space I am finding it difficult to write the contents to the table.
Any help is most appreciated..!

Cheers,
Ajax

Only came across this today so may be to late.
Changes are in red

Brian

Sub Update()

Dim LRow As Integer

LRow = 1

'Move through records until an empty cell is found in column A
While IsEmpty(Range("B" & CStr(LRow)).Value) = False

'If cell B displays "Extn." then move the row to

If Range("B" & CStr(LRow)).Value = "E" Then
'Move the row
LRow = LRow - 1

avalue = Range("C" & LRow & ":C" & LRow).Value

LRow = LRow + 2
Do While IsEmpty(Range("a" & CStr(LRow)).Value) = True
Range("A" & LRow).Value = avalue
LRow = LRow + 1

Loop

End If
LRow = LRow + 1
Wend

End Sub
 
I think this belongs on the General forum explaining exactly what you require.
Its not my strength even tho ' I suspect that I could work my way there given time.

Brian
 

Users who are viewing this thread

Back
Top Bottom