473,385 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How can I copy data from a cell to other cells on same line, testing that they are em

Eg Copy A1 to B1 but if B1 is occupied try C1, etc until an empty cell on line 1 is found.
Nov 8 '12 #1
11 1618
zmbd
5,501 Expert Mod 4TB
This is for MS-Excel yes?
Several ways to do this...
My way is to set the home cell and store the value
then use the offset from there to find an empty cell

Please post what you have tried so far remembering to format your code using the <CODE/> button.
Nov 8 '12 #2
NeoPa
32,556 Expert Mod 16PB
  1. Move the selection cursor to cell A1.
  2. Is the value empty?
  3. Yes. All done. Write value here.
  4. No. Using ActiveCell.Offset(0, 1) check cell B1. Is the value empty?
  5. Yes. All done. Write value here.
  6. No. All done. Write the value in ActiveCell.End(xlToRight).Offset(0,1).
Nov 8 '12 #3
Rabbit
12,516 Expert Mod 8TB
Why not just line 6?
Nov 8 '12 #4
NeoPa
32,556 Expert Mod 16PB
Because it wouldn't work for either of the other two situations. That seems rather obvious. Is that really the question you meant to ask?
Nov 9 '12 #5
Rabbit
12,516 Expert Mod 8TB
It seems to me the OP only has one scenario. Copy one cell to the first blank cell to the right of said cell.
Nov 9 '12 #6
NeoPa
32,556 Expert Mod 16PB
:Confused:
... and that would not be achieved by using line #6 alone - but would be by following the steps as outlined.

This seems very straightforward to me. Am I missing something?
Nov 9 '12 #7
zmbd
5,501 Expert Mod 4TB
That is what I gathered from OP's post too... kinda reminds me of a homework assignment which is why I asked for OP's code.
Normally I do this with range names and gotos to move imported data from one spot to another... then I found the transferworksheet method and YEA done on the export!
Nov 9 '12 #8
NeoPa
32,556 Expert Mod 16PB
Zmbd:
then I found the transferworksheet method and YEA done on the export!
Now you're confusing me Z. This is about identifying which cell in row 1 is the first blank one from the left. My thought was to use the Ctrl-Arrow approach which skips from one end of a block of cells to the other. Clearly there's no call for skipping across if A1 is already a free cell. If A1 has data but is only one cell wide (IE. B1 is empty) then Ctrl-RightArrow takes it across to the next block (which does us no good), so we have to allow for that.

Hence post #3 which lays out all the necessary steps in order to be guaranteed to find the first empty cell of the row.
Nov 9 '12 #9
zmbd
5,501 Expert Mod 4TB
Let's see what OP has for us to work with... between us we've given the information needed to solve the question.
Besides, it strikes me as an homework question the more I read it.
Nov 9 '12 #10
Rabbit
12,516 Expert Mod 8TB
I see now, I forgot that if it starts near a blank cell, it jumps to the very end of the spreadsheet.
Nov 9 '12 #11
NeoPa
32,556 Expert Mod 16PB
Indeed. If the cell to the right is blank then it will go to the next non-blank cell on its right. If there are no more in the row then it will go to the far-right cell of the row.

This behaviour can be seen and experimented with by using the Ctrl key with one of the arrow keys or else pressing the End key followed by one of the arrow keys.
Nov 9 '12 #12

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

Similar topics

14
by: MSR | last post by:
I have a couple of questions. 1. Copy Constructor. class A { private: int a1; double d1; char *ptr;
3
by: tdmailbox | last post by:
I need to migrate data from one sql database to another. The second DB is a newer version of the "old" database with mostly the same tables and fieldnames. In order support some reporting queries...
0
by: Banx | last post by:
Hi everyone, i'm trying to copy data from a table in Pervasive database to a table in MySQL Does anyone know how to do it? :confused: Is it posible to copy data from another database prog to...
1
by: david | last post by:
Hi, I have an Access app which has data for our product range set-up as follows: Main Form: General Product Data Sub Form (within Main Form): Low Level Data Buttons on main form linking to...
2
by: Chris Bellini | last post by:
Greetings! I'm developing a C# application that needs to read some data from a selected XLS file. I've used VB in the past to automate Excel but this is the first time I've used C#. Back in VB,...
4
by: JIM.H. | last post by:
Hello, I am trying to write the data I got from a web service to my table in SQL Server I need to append the dataset wsDS to the dataset ds and do update. PVS.myWS.Loader load = new...
2
by: charles-brewster | last post by:
I'm trying to write a simple JavaScript function which will use a button to copy table cell data into a form input text box as the "value" attribute. The following is intended to test the...
8
by: rfox | last post by:
My parade of IE problems continues. I have two divs in the banner area of my website, one containing a photograph, the other the title and logo for the program. (Please see...
7
by: zeeshanks | last post by:
On adding the rows, they all are showing up on same line instead. For Each objResult In objResultResponse.SearchResultItemArray With row.Cells .Add(ItemIdCell) ...
1
by: DerrickProcurement | last post by:
I have no visual basic experience and all answers I have found required that I had some experience. I hope the questions is simple and that a professional can easily provide me with the proper code...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...

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.