Edit Clear contents of cells in CommonSheet to sheet name

RAJESH1960

Banned for repeated rules violations
Joined
Mar 26, 2020
Messages
2,313
Office Version
  1. 2019
Platform
  1. Windows
Hello JohnnyL,
When I press the first button Generate Master xml. there are 3 rows in Import masters sheet. When I press the second button Generate Purchase xml it deletes all the rows except the first which it doesn't as it is not at all connected to purchase xml. The good thing the master xml has generated 3 rows of data and saved it on the desktop but the question is why is it deleting the data. Is the common sheet code connected to both master and purchase codes? Can you edit the code from deleting the data in the Import Master sheet.?
Rich (BB code):
Sub ClearCommonDataFromSheet(CommonSheet As Worksheet)
'
    Dim LastRowInCommonSheet        As Long
    Dim LastColumnLetterCommonSheet As String
'
    With CommonSheet
        LastColumnLetterCommonSheet = Split(Cells(1, (.Cells.Find("*", _
            , xlFormulas, , xlByColumns, xlPrevious).Column)).Address, "$")(1)                  ' Get last column letter used in CommonSheet
        LastRowInCommonSheet = .Cells.Find("*", , xlFormulas, , xlByRows, xlPrevious).Row       ' Find last row # used in CommonSheet
        .Range("A3:" & LastColumnLetterCommonSheet & LastRowInCommonSheet + 1).ClearContents    ' Clear contents of cells in CommonSheet
    End With
End Sub
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Sorry, I don't understand the question. Can you rephrase your question?
 
Upvote 0
Could be just as easy
VBA Code:
.range(.cells(3,1),.cells(lastrw,lastcolumn)).clearcontents
 
Upvote 0
Sorry, I don't understand the question. Can you rephrase your question?
if you run the purchase import xml using F8 and keep the import master sheet in view, you will notice that it is deleting all the rows except the first one whereas it has not to do anything with the import master sheet.
 
Upvote 0
Could be just as easy
VBA Code:
.range(.cells(3,1),.cells(lastrw,lastcolumn)).clearcontents
I don't want it to delete the data of import master sheet which is included in the common sheet. Common sheets are Import master sheet, purchase data sheet and Import purchase sheet.
 
Upvote 0
if you run the purchase import xml using F8 and keep the import master sheet in view, you will notice that it is deleting all the rows except the first one whereas it has not to do anything with the import master sheet.

If I recall correctly, that is how you wanted it set up. You wanted all the sheets cleared.
 
Upvote 0
If I recall correctly, that is how you wanted it set up. You wanted all the sheets cleared.
That is when I want to clear the old data and use a new data. When I run the code it will display the number of rows in import masters, purchase data and Import purchase sheets. Not to worry, as I said the xml has captured all the 3 rows before getting deleted. This is actually not an issue, but it shouldn't delete the Import master data when I run the generate purchase xml code. Just curiosity and trying to get it corrected if possible.
 
Upvote 0
If you don't want it that way now, Look to the 'Sub Pre_XML_Code()' section. That is where it is setup to clear various sheets.

Move the lines of code from there into the individual routines for generating your xml sheets.
 
Upvote 0

Forum statistics

Threads
1,215,460
Messages
6,124,949
Members
449,198
Latest member
MhammadishaqKhan

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