PC Review


Reply
Thread Tools Rate Thread

Copy data into blank cells

 
 
drinese18
Guest
Posts: n/a
 
      5th Feb 2008
I'm trying to create a macro that will check to see which cells are blank
within the worksheet and copy data from another worksheet into the blank
cells. The tricky part is that the sheet already has data on it and I don't
want it to be sorted or anything of such, I just want the macro to take data
from one cell on a sheet and places it into another cell on another sheet
without affecting the data that is already on the sheet, if anyone can help
me with this that would be great

Thank you
 
Reply With Quote
 
 
 
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      5th Feb 2008
Hi
in general
Set FromSheet = Worksheets("DataFromHere")
Set ToSheet = Worksheets("DataToHere")

If Trim(ToSheet.Range("B1"))="" then
ToSheet.Range("B1").Value = FromSheet.Range("B1").Value
End if

This will copy data from B1 on the FromSheet to B1 on the ToSheet (if
it is originally blank).
You probably need more than this?
regards
Paul


On Feb 5, 2:40*pm, drinese18 <drines...@discussions.microsoft.com>
wrote:
> I'm trying to create a macro that will check to see which cells are blank
> within the worksheet and copy data from another worksheet into the blank
> cells. The tricky part is that the sheet already has data on it and I don't
> want it to be sorted or anything of such, I just want the macro to take data
> from one cell on a sheet and places it into another cell on another sheet
> without affecting the data that is already on the sheet, if anyone can help
> me with this that would be great
>
> Thank you


 
Reply With Quote
 
drinese18
Guest
Posts: n/a
 
      5th Feb 2008
It worked in some ways but it didn't basically search for the blank cells, if
I want it to search for the blank cells within the primary worksheet and
compare it to the secondary worksheet, then if there is data in a similiar
cell as the primary worksheet copy that, how do I go about that, should be If
cells = Null? or something of that sort?

"(E-Mail Removed)" wrote:

> Hi
> in general
> Set FromSheet = Worksheets("DataFromHere")
> Set ToSheet = Worksheets("DataToHere")
>
> If Trim(ToSheet.Range("B1"))="" then
> ToSheet.Range("B1").Value = FromSheet.Range("B1").Value
> End if
>
> This will copy data from B1 on the FromSheet to B1 on the ToSheet (if
> it is originally blank).
> You probably need more than this?
> regards
> Paul
>
>
> On Feb 5, 2:40 pm, drinese18 <drines...@discussions.microsoft.com>
> wrote:
> > I'm trying to create a macro that will check to see which cells are blank
> > within the worksheet and copy data from another worksheet into the blank
> > cells. The tricky part is that the sheet already has data on it and I don't
> > want it to be sorted or anything of such, I just want the macro to take data
> > from one cell on a sheet and places it into another cell on another sheet
> > without affecting the data that is already on the sheet, if anyone can help
> > me with this that would be great
> >
> > Thank you

>
>

 
Reply With Quote
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      5th Feb 2008
Suspected you wanted something more:
How about

Dim FromArray as Variant
Dim ToRange as Range
FromArray = Worksheets("DataFromHere").Range("A1:C6") .Value
Set ToRange = Worksheets("DataToHere").Range("A1:C6")

FromRows = UBound(FromArray,1)
FromColumns = UBound(FromArray, 2)

With ToRange
For i = 1 to FromRows
For j = 1 to FromColumns
If Trim(.Cells(i,j).Value)="" then
.Cells(i,j).Value = FromArray(i,,j)
End if
Next j
Next i
End With

regards
Paul
On Feb 5, 3:27*pm, drinese18 <drines...@discussions.microsoft.com>
wrote:
> It worked in some ways but it didn't basically search for the blank cells,if
> I want it to search for the blank cells within the primary worksheet and
> compare it to the secondary worksheet, then if there is data in a similiar
> cell as the primary worksheet copy that, how do I go about that, should beIf
> cells = Null? or something of that sort?
>
>
>
> "paul.robin...@it-tallaght.ie" wrote:
> > Hi
> > in general
> > Set FromSheet = Worksheets("DataFromHere")
> > Set ToSheet = Worksheets("DataToHere")

>
> > If Trim(ToSheet.Range("B1"))="" then
> > * * ToSheet.Range("B1").Value = FromSheet.Range("B1").Value
> > End if

>
> > This will copy data from B1 on the FromSheet to B1 on the ToSheet (if
> > it is originally blank).
> > You probably need more than this?
> > regards
> > Paul

>


> > On Feb 5, 2:40 pm, drinese18 <drines...@discussions.microsoft.com>
> > wrote:
> > > I'm trying to create a macro that will check to see which cells are blank
> > > within the worksheet and copy data from another worksheet into the blank
> > > cells. The tricky part is that the sheet already has data on it and I don't
> > > want it to be sorted or anything of such, I just want the macro to take data
> > > from one cell on a sheet and places it into another cell on another sheet
> > > without affecting the data that is already on the sheet, if anyone canhelp
> > > me with this that would be great

>
> > > Thank you- Hide quoted text -

>
> - Show quoted text -


 
Reply With Quote
 
drinese18
Guest
Posts: n/a
 
      5th Feb 2008
It works better but it still doesn't check for the blank cell within the
Range A1:C6, after it has checked the range to see if its blank it should
basically copy data from the same cell in the secondary worksheet into the
blank cell in the primary worksheet

"(E-Mail Removed)" wrote:

> Suspected you wanted something more:
> How about
>
> Dim FromArray as Variant
> Dim ToRange as Range
> FromArray = Worksheets("DataFromHere").Range("A1:C6") .Value
> Set ToRange = Worksheets("DataToHere").Range("A1:C6")
>
> FromRows = UBound(FromArray,1)
> FromColumns = UBound(FromArray, 2)
>
> With ToRange
> For i = 1 to FromRows
> For j = 1 to FromColumns
> If Trim(.Cells(i,j).Value)="" then
> .Cells(i,j).Value = FromArray(i,,j)
> End if
> Next j
> Next i
> End With
>
> regards
> Paul
> On Feb 5, 3:27 pm, drinese18 <drines...@discussions.microsoft.com>
> wrote:
> > It worked in some ways but it didn't basically search for the blank cells, if
> > I want it to search for the blank cells within the primary worksheet and
> > compare it to the secondary worksheet, then if there is data in a similiar
> > cell as the primary worksheet copy that, how do I go about that, should be If
> > cells = Null? or something of that sort?
> >
> >
> >
> > "paul.robin...@it-tallaght.ie" wrote:
> > > Hi
> > > in general
> > > Set FromSheet = Worksheets("DataFromHere")
> > > Set ToSheet = Worksheets("DataToHere")

> >
> > > If Trim(ToSheet.Range("B1"))="" then
> > > ToSheet.Range("B1").Value = FromSheet.Range("B1").Value
> > > End if

> >
> > > This will copy data from B1 on the FromSheet to B1 on the ToSheet (if
> > > it is originally blank).
> > > You probably need more than this?
> > > regards
> > > Paul

> >

>
> > > On Feb 5, 2:40 pm, drinese18 <drines...@discussions.microsoft.com>
> > > wrote:
> > > > I'm trying to create a macro that will check to see which cells are blank
> > > > within the worksheet and copy data from another worksheet into the blank
> > > > cells. The tricky part is that the sheet already has data on it and I don't
> > > > want it to be sorted or anything of such, I just want the macro to take data
> > > > from one cell on a sheet and places it into another cell on another sheet
> > > > without affecting the data that is already on the sheet, if anyone can help
> > > > me with this that would be great

> >
> > > > Thank you- Hide quoted text -

> >
> > - Show quoted text -

>
>

 
Reply With Quote
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      5th Feb 2008
Hi
That check is exactly what the line
If Trim(.Cells(i,j).Value)="" then

does. No? Did you leave out the dot in front of Cells maybe??
regards
Paul

On Feb 5, 4:06*pm, drinese18 <drines...@discussions.microsoft.com>
wrote:
> It works better but it still doesn't check for the blank cell within the
> Range A1:C6, after it has checked the range to see if its blank it should
> basically copy data from the same cell in the secondary worksheet into the
> blank cell in the primary worksheet
>
>
>
> "paul.robin...@it-tallaght.ie" wrote:
> > Suspected you wanted something more:
> > How about

>
> > Dim FromArray as Variant
> > Dim ToRange as Range
> > FromArray = Worksheets("DataFromHere").Range("A1:C6") .Value
> > Set ToRange = Worksheets("DataToHere").Range("A1:C6")

>
> > FromRows = UBound(FromArray,1)
> > FromColumns = UBound(FromArray, 2)

>
> > With ToRange
> > For i = 1 to FromRows
> > *For j = 1 to FromColumns
> > * *If Trim(.Cells(i,j).Value)="" then
> > * * .Cells(i,j).Value = FromArray(i,,j)
> > * *End if
> > *Next j
> > Next i
> > End With

>
> > regards
> > Paul
> > On Feb 5, 3:27 pm, drinese18 <drines...@discussions.microsoft.com>
> > wrote:
> > > It worked in some ways but it didn't basically search for the blank cells, if
> > > I want it to search for the blank cells within the primary worksheet and
> > > compare it to the secondary worksheet, then if there is data in a similiar
> > > cell as the primary worksheet copy that, how do I go about that, should be If
> > > cells = Null? or something of that sort?

>
> > > "paul.robin...@it-tallaght.ie" wrote:
> > > > Hi
> > > > in general
> > > > Set FromSheet = Worksheets("DataFromHere")
> > > > Set ToSheet = Worksheets("DataToHere")

>
> > > > If Trim(ToSheet.Range("B1"))="" then
> > > > * * ToSheet.Range("B1").Value = FromSheet.Range("B1").Value
> > > > End if

>
> > > > This will copy data from B1 on the FromSheet to B1 on the ToSheet (if
> > > > it is originally blank).
> > > > You probably need more than this?
> > > > regards
> > > > Paul

>
> > > > On Feb 5, 2:40 pm, drinese18 <drines...@discussions.microsoft.com>
> > > > wrote:
> > > > > I'm trying to create a macro that will check to see which cells are blank
> > > > > within the worksheet and copy data from another worksheet into theblank
> > > > > cells. The tricky part is that the sheet already has data on it and I don't
> > > > > want it to be sorted or anything of such, I just want the macro totake data
> > > > > from one cell on a sheet and places it into another cell on another sheet
> > > > > without affecting the data that is already on the sheet, if anyonecan help
> > > > > me with this that would be great

>
> > > > > Thank you- Hide quoted text -

>
> > > - Show quoted text -- Hide quoted text -

>
> - Show quoted text -


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy an intial cells contents into the next series of blank cells ina column freeriderxlt Microsoft Excel Discussion 2 25th Aug 2009 07:47 AM
copy data from one worksheet and disregard blank cells Allan Microsoft Excel Misc 6 20th Oct 2008 07:40 AM
Copy to first Blank cell in Colum C Non blank cells still exist be =?Utf-8?B?VWxyaWsgbG92ZXMgaG9yc2Vz?= Microsoft Excel Programming 2 8th Oct 2006 07:35 PM
copy text of cells down to blank cells =?Utf-8?B?YW5kcmVzZzE5NzU=?= Microsoft Excel Programming 3 5th Oct 2006 07:14 PM
Copy data from above rows in cells are blank =?Utf-8?B?aXIyNjEyMTk3Mw==?= Microsoft Excel Programming 5 31st Aug 2006 05:00 PM


Features
 

Advertising
 

Newsgroups
 


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