473,549 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Excel Row copy through VBA

3 New Member
Hi,

I am seeking a help from all excel VBA expert.

I have attached the excel file for reference.

In the "Input" sheet there is production schedule that will be generated on submit button click. And the same schedule will also have to COPIED in "Output" sheet. But I am not able to paste it in desired location (blue highlighted area).

Another challenge for me to retain relevant data corresponding to year and clear the rest.
That means suppose its a schdule for 34 Years, now if I again generate it with 20 years it will keep the values of class I and class II till 20 years only and clear the rest.

The same has to be in Output sheet also.

Some one please help at earliest.

Thanks and regards,

Santosh

The code within Submit_Click:

Expand|Select|Wrap|Line Numbers
  1. Sub Submit_Click()
  2. Dim no_years As Integer
  3. Dim i_val As Integer
  4. Range("c10").Activate
  5.  
  6. ActiveCell.EntireRow.Clear
  7.  
  8. ActiveCell = Range("b3").Value
  9. no_years = Range("b4").Value
  10. i_val = Range("b5").Value
  11.  
  12.  
  13. Do While no_years > 0
  14. ActiveCell.Offset(0, 1).Activate
  15. ActiveCell.Value = DateAdd("YYYY", i_val, ActiveCell.Offset(0, -1).Value)
  16.  
  17. no_years = no_years - 1
  18.  
  19. Loop
  20.  
  21. ' copy production schedule calender to all sheets
  22. ActiveCell.EntireRow.Copy Destination:=Sheets("Output").Range("A" & Rows.Count).End(xlUp).Offset(1)
  23.  
  24. MsgBox ("Production schedule calendar generated")
  25. End Sub
Attached Files
File Type: xlsx VBA_Sample.xlsx (18.9 KB, 377 views)
Jun 4 '15 #1
3 3273
zmbd
5,501 Recognized Expert Moderator Expert
skg0009,
+ For various reasons, most of us will not open unrequested attachments.

+ One question per thread.

Line22 is too much.
Say I have a table Range Sheet1!A1:C4 that I want to copy to sheet2 starting in cell Z5... then
Expand|Select|Wrap|Line Numbers
  1.     Worksheets("sheet1").Range("A1").Select
  2.     Selection.CurrentRegion.Select
  3.     Selection.Copy Destination:=Worksheets("Sheet2").Range("Z5")
  4.     Range("A1").Select
There are a ton of other methods... this is the more straight forward of them and works for a contiguous region of data. You can of course select the data range using various methods.

the above will answer part of your second question too with a bit of thought and novel application.
Jun 24 '15 #2
skg0009
3 New Member
Thanks a lot.
Can you give me an idea, how do I clear irrelevant data, for ex, after copy and paste new data place in sheet 2 from cell Z5 to AI5, but already few data exist in sheet 2 till AI6.

How do I clear this extra cell data ?

Regards,
Jun 24 '15 #3
zmbd
5,501 Recognized Expert Moderator Expert
new question new thread please
Jun 24 '15 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
3142
by: Nathan | last post by:
A couple of months ago, I went looking for a .NET grid component with what I thought was pretty simple criteria - I wanted an interface that provided my users with Excel-like data entry capability. My users (mostly scientists) use Excel for just about everything and like how quick and easy it is to manipulte tabular data in Excel. For...
0
1607
by: Kay | last post by:
Hi all, I want to copy an entire row from a worksheet to another worksheet, when I set the excel app = visible and step thru the code I can actally see a row is appended to another worksheet, but just last a flash, and , anyone know what's going wrong? Dim oApp As New Excel.Application Dim oWBa As Excel.Workbook =...
0
3617
by: keithsimpson3973 | last post by:
I have the following code to populate an excel spreadsheet from vb6 and access database. It works great except that when it reads from the recordset and populates the spreadsheet, I would like it to populate every other line in the spreadsheet. I can't seem to see anywhere in the code where that might be handled. Any help would be greatly...
0
1505
by: six888 | last post by:
i need to make a report using excel. im given a few data in excel document for a 1 month report (1 document for each week). each data document have a few work sheet.i need only certain information in each week data. before this i do it manually by copy-paste each information i want to a new excel where i compile all the data for the month.i want...
2
2772
by: OfficeDummy | last post by:
Hi, everyone! Like I mentioned in the thread title, I need to copy&paste data between different workbooks, and it works fine. However, when the data has been copied to the destination workbook, the grid disappears. Why, and how can I get it back? Thanks a lot in advance! Best, OfficeDummy
0
3184
by: Taxman | last post by:
Windows XP, MS Office Excel 2003 If the tasks, I’m trying accomplish have been addressed previously (separately or in combination). Please, provide the links or keyword search to find them. I’ve been searching for code for each part of the task separately and trying to piece together multiple macros, that do something similar, to what I’m...
4
3029
by: Gustavo Cesar | last post by:
Friends, I need to build a loop on VBA Excel to do the following routine: 1o Action: Select entire row #1 and copy 2o Action: Select entire row #2 and Paste Special -> Formulas 3o Action: Select entire row #1 and Paste Special -> Values 4o Action: Select entire row #2 and copy 5o Action: Select entire row #3 and Paste Special -> Formulas...
5
2077
by: sandy armstrong | last post by:
Hello everyone I have a question??? can excel copy data from mulitiple worksheets then paste it into a summary workbook then every time the orginal file is change or anything is added it also refects on the summary workbook I appreactice the help
7
2955
by: sandy armstrong | last post by:
Hello and goodMorning, Can anyone please help me with this. I have a database in excel that has 2 sheets full of data. I would like if i press a button to update then macro searches in Column O if the words " Req. Feed Set Up" then it get move over to sheet 2 in the workbook. Sub Feed_set_up() Dim intLastRow As Long intLastRow =...
0
7461
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7730
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7971
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7491
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7823
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1068
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.