ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   save original data after macro is run again (https://www.excelbanter.com/new-users-excel/34052-save-original-data-after-macro-run-again.html)

MINAL ZUNKE

save original data after macro is run again
 
Hi
Experts

I have developed a macro which imports data from another excel file.
Ex: consider I have 2 excel files A & B.
I run macro in file A today, it copies whatever data from file B.
say 20 rows have been filled in file A(starting from A5 to A25). I do some
changes on the file A which has few conditional formatting and forlumas.
I re-run the macro after 8 days in file A to get the new updated data from
file B.

The problem I am facing is
"If I re-run the macro, it deletes the data from file A. It pastes
everything starting from top left cell.
When I generated macro in file A, I have selected top left cell while
recording macro.

My requirement::::::
Now I want the macro to put the data from the cell A27 onwards and also
retain the changes to the data from Cell A5 to A25.
So everytime I run the macro it should add data to the excel file from the
available blank cell and not copy over the same data.

Thnanking in anticipation

Bernie Deitrick

Minal,

Posting your code would help. But, perhaps a change from code like:

Range("A5").Select

to

Range("A65536").End(xlUp)(2).Select

will fix that problem.

HTH,
Bernie
MS Excel MVP


"MINAL ZUNKE" wrote in message
...
Hi
Experts

I have developed a macro which imports data from another excel file.
Ex: consider I have 2 excel files A & B.
I run macro in file A today, it copies whatever data from file B.
say 20 rows have been filled in file A(starting from A5 to A25). I do some
changes on the file A which has few conditional formatting and forlumas.
I re-run the macro after 8 days in file A to get the new updated data from
file B.

The problem I am facing is
"If I re-run the macro, it deletes the data from file A. It pastes
everything starting from top left cell.
When I generated macro in file A, I have selected top left cell while
recording macro.

My requirement::::::
Now I want the macro to put the data from the cell A27 onwards and also
retain the changes to the data from Cell A5 to A25.
So everytime I run the macro it should add data to the excel file from the
available blank cell and not copy over the same data.

Thnanking in anticipation




MINAL ZUNKE

hi Bernie

I have pasted code here

Windows("Qry_CNC MILL_JOB.xls").Activate
Range("A2:E100").Select
ActiveWindow.SmallScroll Down:=-87
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 1
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 1
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 1
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 1
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 1
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 1
End With
Selection.Copy
Windows("job status xcel.xls").Activate
Range("A5").Select
ActiveSheet.Paste
Range("F7").Select
Application.CutCopyMode = False
ActiveWorkbook.Save
End Sub

I hope to have a workable solution from you.
thnx


"Bernie Deitrick" wrote:

Minal,

Posting your code would help. But, perhaps a change from code like:

Range("A5").Select

to

Range("A65536").End(xlUp)(2).Select

will fix that problem.

HTH,
Bernie
MS Excel MVP


"MINAL ZUNKE" wrote in message
...
Hi
Experts

I have developed a macro which imports data from another excel file.
Ex: consider I have 2 excel files A & B.
I run macro in file A today, it copies whatever data from file B.
say 20 rows have been filled in file A(starting from A5 to A25). I do some
changes on the file A which has few conditional formatting and forlumas.
I re-run the macro after 8 days in file A to get the new updated data from
file B.

The problem I am facing is
"If I re-run the macro, it deletes the data from file A. It pastes
everything starting from top left cell.
When I generated macro in file A, I have selected top left cell while
recording macro.

My requirement::::::
Now I want the macro to put the data from the cell A27 onwards and also
retain the changes to the data from Cell A5 to A25.
So everytime I run the macro it should add data to the excel file from the
available blank cell and not copy over the same data.

Thnanking in anticipation





Bernie Deitrick

Change

Range("A5").Select
ActiveSheet.Paste


to

Range("A65536").End(xlUp)(2).Select
ActiveSheet.Paste

Bernie


"MINAL ZUNKE" wrote in message
...
hi Bernie

I have pasted code here

Windows("Qry_CNC MILL_JOB.xls").Activate
Range("A2:E100").Select
ActiveWindow.SmallScroll Down:=-87
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 1
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 1
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 1
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 1
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 1
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 1
End With
Selection.Copy
Windows("job status xcel.xls").Activate
Range("A5").Select
ActiveSheet.Paste
Range("F7").Select
Application.CutCopyMode = False
ActiveWorkbook.Save
End Sub

I hope to have a workable solution from you.
thnx


"Bernie Deitrick" wrote:

Minal,

Posting your code would help. But, perhaps a change from code like:

Range("A5").Select

to

Range("A65536").End(xlUp)(2).Select

will fix that problem.

HTH,
Bernie
MS Excel MVP


"MINAL ZUNKE" wrote in message
...
Hi
Experts

I have developed a macro which imports data from another excel file.
Ex: consider I have 2 excel files A & B.
I run macro in file A today, it copies whatever data from file B.
say 20 rows have been filled in file A(starting from A5 to A25). I do
some
changes on the file A which has few conditional formatting and
forlumas.
I re-run the macro after 8 days in file A to get the new updated data
from
file B.

The problem I am facing is
"If I re-run the macro, it deletes the data from file A. It pastes
everything starting from top left cell.
When I generated macro in file A, I have selected top left cell while
recording macro.

My requirement::::::
Now I want the macro to put the data from the cell A27 onwards and
also
retain the changes to the data from Cell A5 to A25.
So everytime I run the macro it should add data to the excel file from
the
available blank cell and not copy over the same data.

Thnanking in anticipation








All times are GMT +1. The time now is 08:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com